View source: R/strings_utils.R
gseq | R Documentation |
Replaces a sequence of strings
gseq(x, pattern = "", replacement = character(), all = TRUE)
x , pattern , replacement |
non empty character vectors. |
all |
whether to replace all instances of 'pattern' or only the 1st one. Default is TRUE, to replace all instances. |
if 'pattern' is found within 'x', 'pattern' will be removed from 'x' and replace by 'replacement'.
It looks like gsub but it is different e.g.:
x=c("ABD","A","B")
pattern=c("A","B")
replacement=c("C")
- gsub(x=paste0(x,collapse=""),pattern=paste0(pattern,collapse=""),replacement=paste0(replacement,collapse=""),fixed=TRUE) will give "CDC",
- gseq(x=x,pattern=pattern,replacement=replacement) will give "ABD","C".
'x' where 'pattern' is replaced by replacement.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.