gseq {IFC} | R Documentation |
String Sequence Replacement
Description
Replaces a sequence of strings
Usage
gseq(x, pattern = "", replacement = character(), all = TRUE)
Arguments
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. |
Details
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".
Value
'x' where 'pattern' is replaced by replacement.
[Package IFC version 0.2.1 Index]