An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130620/241ec99e/attachment.pl>
how to add any extra word to existing column heading in R
5 messages · suparna mitra, Pascal Oettli, John Kane
Hello, What did you try to do by yourself before to ask? Regards, Pascal
On 20/06/13 13:56, Suparna Mitra wrote:
Hello R experts,
I want to add some extra words to number to existing column header. Can
anybody tell me how to do that.
e.g. if I have a data.frame
Height.1 Height.2 Height.6 Height.8 Height.10 Height.11 Height.17
Height.20 Height.22 Height.31
MBR1 74 72 0 104 0 250 144
0 0 0
MBR2 0 94 0 150 0 250 158
0 0 0
MBR3 93 167 0 199 0 250 208
0 0 0
MBR4 146 106 0 165 0 250 135
0 0 0
MBR5 149 106 0 0 0 250 141
0 0 0
MBR6 120 0 0 97 0 250 175
0 0 0
MBR7 120 0 0 76 145 250 130
0 0 79
MBR8 89 70 0 114 0 250 211
0 0 0
I want to rename the heading as
Height.1.D1 Height.2.D1 Height.6.D1 Height.8.D1 Height.10.D1
Height.11.D1 Height.17.D1 Height.20.D1 Height.22.D1 Height.31.D1
MBR1 74 72 0 104 0 250 144
0 0 0
MBR2 0 94 0 150 0 250 158
0 0 0
MBR3 93 167 0 199 0 250 208
0 0 0
MBR4 146 106 0 165 0 250 135
0 0 0
MBR5 149 106 0 0 0 250 141
0 0 0
MBR6 120 0 0 97 0 250 175
0 0 0
MBR7 120 0 0 76 145 250 130
0 0 79
MBR8 89 70 0 114 0 250 211
0 0 0
MBR9 168 0 0 0 0 250 137
0 0 0
MBR11 78 68 0 117 0 250 161
0 49 0
Any help will be really great.
Thanks,
Mitra
[[alternative HTML version deleted]]
______________________________________________ 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130620/bf8bcc9c/attachment.pl>
Hello, Two keywords: "colnames" and "paste". Regards, Pascal
On 20/06/13 14:09, Suparna Mitra wrote:
Hello,
I
was trying ways to define new column names. Or very traditional way to
export the data and add names in excel.
But thought there must a way, but searched with several key words in
forum, but couldn't find the exact what I mean.
May be my search terms are not perfect.
Thanks,
Mitra
On 20 June 2013 13:04, Pascal Oettli <kridox at ymail.com
<mailto:kridox at ymail.com>> wrote:
Hello,
What did you try to do by yourself before to ask?
Regards,
Pascal
On 20/06/13 13:56, Suparna Mitra wrote:
Hello R experts,
I want to add some extra words to number to existing column
header. Can
anybody tell me how to do that.
e.g. if I have a data.frame
Height.1 Height.2 Height.6 Height.8 Height.10 Height.11
Height.17
Height.20 Height.22 Height.31
MBR1 74 72 0 104 0 250
144
0 0 0
MBR2 0 94 0 150 0 250
158
0 0 0
MBR3 93 167 0 199 0 250
208
0 0 0
MBR4 146 106 0 165 0 250
135
0 0 0
MBR5 149 106 0 0 0 250
141
0 0 0
MBR6 120 0 0 97 0 250
175
0 0 0
MBR7 120 0 0 76 145 250
130
0 0 79
MBR8 89 70 0 114 0 250
211
0 0 0
I want to rename the heading as
Height.1.D1 Height.2.D1 Height.6.D1 Height.8.D1 Height.10.D1
Height.11.D1 Height.17.D1 Height.20.D1 Height.22.D1 Height.31.D1
MBR1 74 72 0 104 0 250
144
0 0 0
MBR2 0 94 0 150 0 250
158
0 0 0
MBR3 93 167 0 199 0 250
208
0 0 0
MBR4 146 106 0 165 0 250
135
0 0 0
MBR5 149 106 0 0 0 250
141
0 0 0
MBR6 120 0 0 97 0 250
175
0 0 0
MBR7 120 0 0 76 145 250
130
0 0 79
MBR8 89 70 0 114 0 250
211
0 0 0
MBR9 168 0 0 0 0 250
137
0 0 0
MBR11 78 68 0 117 0 250
161
0 49 0
Any help will be really great.
Thanks,
Mitra
[[alternative HTML version deleted]]
________________________________________________
R-help at r-project.org <mailto:R-help at r-project.org> mailing list
https://stat.ethz.ch/mailman/__listinfo/r-help
<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide
http://www.R-project.org/__posting-guide.html
<http://www.R-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.
5 days later
names(height) <- paste0(names(height),".D1") It would be better if you supplied the data using dput() Have a lookt at https://github.com/hadley/devtools/wiki/Reproducibility for some suggestions on forming a good question. John Kane Kingston ON Canada
-----Original Message-----
From: suparna.mitra.sm at gmail.com
Sent: Thu, 20 Jun 2013 12:56:24 +0800
To: r-help at r-project.org
Subject: [R] how to add any extra word to existing column heading in R
Hello R experts,
I want to add some extra words to number to existing column header. Can
anybody tell me how to do that.
e.g. if I have a data.frame
Height.1 Height.2 Height.6 Height.8 Height.10 Height.11 Height.17
Height.20 Height.22 Height.31
MBR1 74 72 0 104 0 250 144
0 0 0
MBR2 0 94 0 150 0 250 158
0 0 0
MBR3 93 167 0 199 0 250 208
0 0 0
MBR4 146 106 0 165 0 250 135
0 0 0
MBR5 149 106 0 0 0 250 141
0 0 0
MBR6 120 0 0 97 0 250 175
0 0 0
MBR7 120 0 0 76 145 250 130
0 0 79
MBR8 89 70 0 114 0 250 211
0 0 0
I want to rename the heading as
Height.1.D1 Height.2.D1 Height.6.D1 Height.8.D1 Height.10.D1
Height.11.D1 Height.17.D1 Height.20.D1 Height.22.D1 Height.31.D1
MBR1 74 72 0 104 0 250 144
0 0 0
MBR2 0 94 0 150 0 250 158
0 0 0
MBR3 93 167 0 199 0 250 208
0 0 0
MBR4 146 106 0 165 0 250 135
0 0 0
MBR5 149 106 0 0 0 250 141
0 0 0
MBR6 120 0 0 97 0 250 175
0 0 0
MBR7 120 0 0 76 145 250 130
0 0 79
MBR8 89 70 0 114 0 250 211
0 0 0
MBR9 168 0 0 0 0 250 137
0 0 0
MBR11 78 68 0 117 0 250 161
0 49 0
Any help will be really great.
Thanks,
Mitra
[[alternative HTML version deleted]]
______________________________________________ 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.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!