View source: R/transcripts_rename.R
transcripts_rename | R Documentation |
Rename transcript objects in a corpus object.
This function changes both the names of the transcripts in the list x@transcripts
and in the @name
slot of the transcript.
The function ensures that each transcript object preserves a unique name.
transcripts_rename( x, newTranscriptNames = NULL, searchPatterns = NULL, searchReplacements = NULL, toUpperCase = FALSE, toLowerCase = FALSE, trim = FALSE, stopIfNotUnique = TRUE )
x |
Corpus object |
newTranscriptNames |
Vector of character strings; new names for the transcripts. If left open, the current names in the corpus object will be taken as basis. |
searchPatterns |
Character string; Search pattern as regular expression applied to the names of the transcripts. |
searchReplacements |
Character string; String to replace the hits of the search. |
toUpperCase |
Logical; Convert transcript names all to upper case. |
toLowerCase |
Logical; Convert transcript names all to lower case. |
trim |
Logical; Remove leading and trailing spaces in names. |
stopIfNotUnique |
Logical; If |
Corpus object
library(act) # get current names old.names <- names(examplecorpus@transcripts) # make vector of names with the same length new.names <- paste("transcript", 1:length(old.names), sep="") # rename the transcripts test <- act::transcripts_rename(examplecorpus, newTranscriptNames=new.names) # check names(test@transcripts) test@transcripts[[1]]@name test@history[length(test@history)] # convert to lower case test <- act::transcripts_rename(examplecorpus, toLowerCase=TRUE) test@history[length(test@history)] # search replace test <- act::transcripts_rename(examplecorpus, searchPatterns=c("ARG", "BOL"), searchReplacements = c("ARGENTINA", "BOLIVIA") ) test@history[length(test@history)] # search replace ignoring upper and lower case test <- act::transcripts_rename(examplecorpus, searchPatterns=c("(?i)arg", "(?i)bol"), searchReplacements = c("ARGENTINA", "BOLIVIA") ) test@history[length(test@history)] # search replace too much test <- act::transcripts_rename(x=examplecorpus, searchPatterns="ARG_I_CHI_Santi", searchReplacements = "") names(test@transcripts)[1]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.