Hi,

I have a vector of strings (categories), each element of which can be
uniquely found in each element of a much longer vector of about 30 or so
differeint factors. I would like to define another factor variable (drawn
from NewFactorListaccording to which string from "categories" is found in
the longer string of factors. Then I'd do it again, with another set of
categories, and make a table based on the new factors. The last part is
easy, but I've never had luck with string manipulation in R.

for(j in 1:length(categories)){
  for(i in 1:nrow(data)){
    ifelse(categories[j] %in% as.character(d1[i,
"col"),data$NewFactor[i]<-NewFactorList[j], data$Check<-"NotYet")
  }
}

Thanks,

Ben

        [[alternative HTML version deleted]]

______________________________________________
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