Suparna Mitra
2013-Jun-20  04:56 UTC
[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]]
Pascal Oettli
2013-Jun-20  05:04 UTC
[R] how to add any extra word to existing column heading in R
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. >
John Kane
2013-Jun-25  16:34 UTC
[R] how to add any extra word to existing column heading in R
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!