Friday, April 8, 2011

String operations in R

search and replace functions:
replace first occurrence:
- sub(pattern, replacement, x, = FALSE)
and replace all occurences:
- gsub(pattern, replacement, x, = FALSE)
sub("ich", "wir", "ich Ich ICH") --------> "wir Ich ICH"
sub("ich", "wir", "ich Ich ICH", --------> "wir Ich ICH"
gsub("ich", "wir", "ich Ich ICH",> "wir wir wir"

useful packages:
- gsubfn -> Homepage

No comments :

Post a Comment