Once again I need to tap into the collective knowledge here.
Let's say I have the following columns and data below Y X1 X2 X3 X4 I would like to generate additional new columns and column names (ie the data would be squared - and I'd like the column names to reflect this) like: Y X1 X2 X3 X4 X1^2 X2^2 X3^2 X4^2 I believe I can compute the values correctly with the code below, but I am unable to generate the column names. (This is a short example, in reality I have many more columns and more complicated names) for(i in 2:5) { name=get(paste(names(simpleData)[i],"^2", sep="")) simpleData<- transform(simpleData, name=(simpleData[,i]^2)) } print(simpleData) Any suggestions/hints .. I've searched the FAQ and web (this is how I came across the get() function) but no luck so far. Thanks, Esmail ______________________________________________ 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.