The labels can contain much more than just names. In my case, they are variable descriptions (items from a questionnaire). I need to keep the names as they are, hence the need for Hmisc's labels.
On Mon, Aug 15, 2011 at 3:53 PM, Monsieur Do <nonaupourr...@yahoo.ca> wrote: > I have a dataset and a list of labels. I simply want to apply the labels to the variables, all at once. The only way I was able to do it was using a loop: > > for (i in 1:length(data)) label(data[,i]) <- data.labels[i] > > I'd like to find the non-loop way to do it, using apply or the like... Any help appreciated. Would you not be better off with names()? > data <- 1:10 > data.labels <- letters[1:10] > names(data) <- data.labels > data a b c d e f g h i j 1 2 3 4 5 6 7 8 9 10 What are you trying to do with label() that names() doesn't accomplish? -- Sarah Goslee http://www.functionaldiversity.org [[alternative HTML version deleted]]
______________________________________________ R-help@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.