[R] just a small variable-naming question
arun
smartpink111 at yahoo.com
Sat Aug 24 18:22:30 CEST 2013
Hi,
You could use ?paste()
colnames(myData)<-paste(colnames(myData),paste0("var",1:3),sep="_")
myData
# col1_var1 col2_var2 col3_var3
#1 1 2 3
#2 2 3 4
#3 3 4 5
A.K.
----- Original Message -----
From: Richard Sherman <rss.pdx at gmail.com>
To: r-help at r-project.org
Cc:
Sent: Saturday, August 24, 2013 12:09 PM
Subject: [R] just a small variable-naming question
Hi all,
If I have this little data set:
> myData <- data.frame(col1 = 1:3, col2 =2:4, col3 = 3:5)
> myData
col1 col2 col3
1 1 2 3
2 2 3 4
3 3 4 5
and I want to add (not replace) the names var1, var2, var3 to the existing col1, col2, col3, what is the right way to do that?
Thanks.
-Richard
---
Prof. Richard Sherman
Division of International Studies
Korea University
______________________________________________
R-help at 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.
More information about the R-help
mailing list