Hello

a <- c("Mama", "Papa", "Papa; Mama", "", "Sammy; Mama; Papa")
a <- strsplit(a, "; ")
mama <- rep(F, length(a))
mama[sapply(a, function(x) { sum(x=="Mama") }, simplify=T) > 0] <- T
papa <- rep(F, length(a))
papa[sapply(a, function(x) { sum(x=="Papa") }, simplify=T) > 0] <- T
# ... more variables

... produces the variables "mama" and "papa" correctly. But how do I remove all "Mama" list entries in "a" in the same run, that is, shrink the list by what was already matched?

Thank you for your help!

Sören Vogel


--
Sören Vogel, Dipl.-Psych. (Univ.), PhD-Student, Eawag, Dept. SIAM
http://www.eawag.ch, http://sozmod.eawag.ch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to