On Mon, Mar 14, 2011 at 9:59 AM, ONKELINX, Thierry <thierry.onkel...@inbo.be> wrote: > Something like this? > > my_data=read.table("clipboard", header=TRUE) > my_data$s_name <- factor(my_data$s_name) > library(plyr) > ddply(my_data, .(s_name), function(x){ > x$Im_looking <- x$Depth + as.numeric(x$s_name) / 100 > x > })
I think you need factor in there: ddply(my_data, .(s_name), function(x){ x$Im_looking <- x$Depth + as.numeric(factor(x$s_name)) / 100 x }) or with transform: ddply(my_data, "s_name", transform, Im_looking = Depth + as.numeric(factor(s_name)) / 100) Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ ______________________________________________ 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.