I would like to add an extension to the current name of a variable to create a new variable that is its sqrt transform. Each piece of the equation below works independently, but the left side definition fails on run. I also tried creating the variable name first, but ended up with an object that toString() did not fix. Better ideas?
Example 1 (paste0(emotions[[i]],"_sqrt"))<-sqrt(data[[emotions[i]]]) Example 2 newvar<-toString(paste0(emotions[[i]],"_sqrt")) data$newvar<-sqrt(data[[emotions[i]]]) Example 3 newvar<-toString(paste0(emotions[[i]],"_sqrt")) data$newvar[1]<-sqrt(data[[emotions[i]]]) -- View this message in context: http://r.789695.n4.nabble.com/Efficiently-creating-defining-new-variables-transformations-tp4650401.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.