LCOG1 <jroll <at> lcog.org> writes: [snip]
> > I need to do the same for a fueltype where each record has a character > representing the data instead of a numeral(as in year). No reproducible > code or data because i think this is pretty straight forward. I could do > this using a series of loops but i think there is prob a more elegant way. > Use of grep? Thanks for the help Reproducible would still help because we still have to do a bit of guessing about what you mean. How do you want to define the ordering on characters? If the number of fuel types is small enough, you could just create a factor and cut() on the numeric values , e.g. fueltype <- factor(c("A","A","B","E","Q"),levels=LETTERS) cut(as.numeric(fueltype),c(-0.5,13.5,26.5),labels=c("A-M","N-Z")) ______________________________________________ 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.