Hi guys, Cant seem to find a solution for this. I am looking for a substitute for cut that can transform character vectors. So as cut would be used below to transform YearCat-> YearCat2 base on Year and vector Ag<-c("00-'70","'71-'75","'76-'85","'86-'09") using 'cut ' FleetData$YearCat<-cut(FleetData$Year,c(0,1970,1975,1985,2009),labels=Ag)
Make Year YearCat YearCat2 1 DODG 2003 '86-'09 (2002,2003] 3 FORD 1995 '86-'09 (1994,1995] 5 JEP 1997 '86-'09 (1996,1997] 6 JEP 1997 '86-'09 (1996,1997] 7 DODG 2002 '86-'09 (2001,2002] 8 BMW 1997 '86-'09 (1996,1997] 11 TOYT 2006 '86-'09 (2005,2006] 12 CHEV 1997 '86-'09 (1996,1997] 13 CHEV 1992 '86-'09 (1991,1992] 14 CHEV 1996 '86-'09 (1995,1996] 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 JR -- View this message in context: http://r.789695.n4.nabble.com/Transforming-character-vector-tp2537881p2537881.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.