annotations_delete {act} | R Documentation |
Delete annotations
Description
Delete annotations in a corpus object.
If only certain transcripts or tiers should be affected set the parameter filterTranscriptNames
and filterTierNames
.
In case that you want to select transcripts and/or tiers by using regular expressions use the function act::search_makefilter
first.
Usage
annotations_delete(
x,
pattern = "",
filterTranscriptNames = NULL,
filterTierNames = NULL
)
Arguments
x |
Corpus object. |
pattern |
Character string; regular expression; all annotations that match this expression will be deleted. |
filterTranscriptNames |
Vector of character strings; names of the transcripts to be included. |
filterTierNames |
Character string; names of the tiers to be included. |
Value
Corpus object.
Examples
library(act)
# Set the regular expression which annotations should be deleted.
# In this case: all annotations that contain the letter "a"
myRegEx <- "a"
# Have a look at all annotations in the first transcript
examplecorpus@transcripts[[1]]@annotations$content
# Some of them match to the regular expression
hits <- grep(pattern=myRegEx, x=examplecorpus@transcripts[[1]]@annotations$content)
examplecorpus@transcripts[[1]]@annotations$content[hits]
# Others don't match the regular expression
examplecorpus@transcripts[[1]]@annotations$content[-hits]
# Run the function and delete the annotations that match the regular expression
test <- act::annotations_delete (x=examplecorpus, pattern=myRegEx)
# Compare how many data rows are in the first transcript in
# the example corpus and in the newly created test corpus:
nrow(examplecorpus@transcripts[[1]]@annotations)
nrow(test@transcripts[[1]]@annotations)
# Only the annotations are left, that did not match the regular expression:
test@transcripts[[1]]@annotations$content
[Package act version 1.3.1 Index]