[R] Apply vector of labels to columns of data frame

Steve Powell steve at promente.org
Fri Oct 5 12:51:16 CEST 2007

Thanks Shubha, Petr and Patrick - 
Erm, yes perhaps I wasn't clear, when I said "label" I didn't mean names, I
meant the labels provided by Hmisc. 
So for example

I can do 
label(df$b)="lab2" etc
attributes(df$a)$label="lab1" etc
But I would like to do this with a loop or an apply function.
Thanks and best wishes

Steve Powell
proMENTE social research 
research | evaluation | training & consulting
Kranjčevićeva 35, 71000 Sarajevo 
mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866
skype: stevepowell99 


-----Original Message-----
From: Patrick Burns [mailto:pburns at pburns.seanet.com] 
Sent: 05 October 2007 11:50
To: Steve Powell
Subject: Re: [R] Apply vector of labels to columns of data frame

Your question is not very clear, but is this what you want:

colnames(v) <- paste('lab', 1:ncol(v), sep='')

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
(home of S Poetry and "A Guide for the Unwilling S User")

Steve Powell wrote:

>Dear list members
>I would like to apply a vector of labels
>to a dataframe
>using some kind of loop or apply function.
>Any ideas?
>Steve Powell
>Checked by AVG Free Edition. 
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list
>PLEASE do read the posting guide 
>and provide commented, minimal, self-contained, reproducible code.

No virus found in this incoming message.
Checked by AVG Free Edition. 


Checked by AVG Free Edition. 


More information about the R-help mailing list