Re: [R] R: re: dataframe

2014-04-30 Thread arun
Hi, In this case, you may have to use:  dat1[sapply(dat1,function(x) any(grepl("\\bC\\b",x))) & sapply(dat1,function(x) any(grepl("Au5",x)))] o066_010    o066_022    o066_029    o066_034    o066_068    o066_072 1  sample  sample  sample  sample  sample  sample 2  

Re: [R] R: re: dataframe

2014-04-30 Thread arun
Hi James, I guess the problem was because the columns you tried were factors. Suppose `dat1` is your dataset (first). library(stringr) indx <- grep("sample", colnames(dat1)) toGrep <- read.table(text = str_trim(gsub("[sample.]", " ", colnames(dat1)[indx])),     header = FALSE, stringsAsFactors