[R] Efficiently creating/defining new variables transformations

nprause Nicole.Prause at gmail.com
Thu Nov 22 01:35:55 CET 2012


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.



More information about the R-help mailing list