On Thu, Nov 3, 2011 at 1:31 PM, Zev Ross <z...@zevross.com> wrote: > Hi Peter, > > Thanks for the response. What you've suggested works fine but I'm looking > for something that is simpler than my solution and avoids the pesky warning > message. Your response avoids the warning message but just as complex (if > not more). I just assumed there would be a function along the lines of: > >> mydata <- c("A", "C", "A", "D", "B", "B") >> reclassify(mydata, inCategories=c("A", "B" ,"C", "D"), >> outCategories=c("Group1", "Group1", "Group2", "Group2")) > > [1] "Group1" "Group2" "Group1" "Group2" "Group1" "Group1" >
But of course, except sometimes you have to write the function yourself. reclassify = function(data, inCategories, outCategories) { outCategories[ match(data, inCategories)] } Sorry I can't make it any simpler than a 1-line solution :) Feel free to add some checking of input validity, if you need that. Peter ______________________________________________ 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.