Displaying 1 result from an estimated 1 matches for "var2_new".
Did you mean:
var1_new
2008 Feb 26
2
Combining series of variables using identifier
...var2_lab= rep(c("car", "bicycle", "train", "bus"), each=5))
str(a)
I'd like to create new variables by combining "varX" and "varX_lab" like this:
a$var1_new <- factor(paste(a$var1, a$var1_lab, sep=": "))
a$var2_new <- factor(paste(a$var2, a$var2_lab, sep=": "))
a
But, in the real world, I have multiple df:s and many of variables
named by the same manner. Is there a possibility to create a function
which combines these variables and creates new ones into the same df
using "varX" as an i...