Re: [R] labels to values

2008-01-10 Thread Matthias Wendel
nly if number of distinct labels is equal to number of distinct values. By assuring this (it was not the case for Y6), I've got what I Want. Regards, Matthias -Ursprüngliche Nachricht- Von: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 9. Januar 2008 17:17 An: Ma

Re: [R] labels to values

2008-01-09 Thread John Kane
There probably is an easier way but you put the value.labels and corresponding numbers into a data.frame, stick d[,'Y6] into a data frame and merge the two. Then just add or replace d[,Y6] in the original data.frame. Example # Set up basic data aa <- 1:15 bb <- letters[1:15] # Apply att

Re: [R] labels to values

2008-01-09 Thread Henrique Dallazuanna
If I understand your question, you can do: x1 <- as.factor(d[,'Y6']) levels(x1)[levels(x1) %in% attributes(x)[1]] <- c(names(unlist(lapply(levels(x1), function(z)which(z==attributes(x)[[1]]) On 09/01/2008, Matthias Wendel <[EMAIL PROTECTED]> wrote: > I couldn't find out how the following to s

[R] labels to values

2008-01-09 Thread Matthias Wendel
I couldn't find out how the following to solve: There is a column in a data.frame: > d[, 'Y6'] [1] 6 3 8 11 8 9 6 8 3 5 10 15 NA 9 8 3 8 16 6 6 NA 10 5 2 7 7 6 16 7 15 7 10 12 8 7 12 12 16 7 6 8 8 15 6 [45] NA 8 99 7 12 8 9 16 7 16 8 7 7 1 15 12 8 7 10