[R] how to add any extra word to existing column heading in R

Pascal Oettli kridox at ymail.com
Thu Jun 20 07:19:42 CEST 2013


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.
>
>



More information about the R-help mailing list