Hi Greg,
This is quite helpful. Not so good yet with regular expressions in general or
Perl-like regular expressions. Found the help page though, and think I was able
to determine how the code works as well as how I would select only instances
where "muta" is preceeded by either "non" or "un".
> (tmp <- c('mutation','nonmutated','unmutated','verymutated','other'))
[1] "mutation" "nonmutated" "unmutated" "verymutated" "other"
> grep("(?<!un)(?<!non)muta", tmp, perl=TRUE)
[1] 1 4
> grep("(?!muta)non|un", tmp, perl=TRUE)
[1] 2 3
Did I get the second grep right?
If so, do you have any sense of why it seems to fail when I apply it to my data?
> KRASyn$NonMutant_comb <- rowSums(KRASyn[grep("(?!muta)non|un", names(KRASyn),
> perl=TRUE)])
Error in rowSums(KRASyn[grep("(?!muta)non|un", names(KRASyn), perl = TRUE)]) :
'x' must be numeric
Thanks,
Paul
______________________________________________
[email protected] 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.