[R] Fwd: Re: How to call a value labels attribute?
Richard M. Heiberger
rmh at temple.edu
Sun Jun 4 18:12:54 CEST 2006
How is what you are doing any different from factors?
> x <- factor(c(1, 2, 3, 3, 2, 3, 1), labels=c("apple", "banana", "other"))
> x
[1] apple banana other other banana other apple
Levels: apple banana other
> as.numeric(x)
[1] 1 2 3 3 2 3 1
> levels(x)[3] <- "birne"
> x
[1] apple banana birne birne banana birne apple
Levels: apple banana birne
>
---- Original message ----
>### not run
>### pseudocode
>x <- c(1, 2, 3, 3, 2, 3, 1)
>value.labels(x) <- c(apple=1, banana=2, NA=3)
>x
>### desired result
>apple banana NA NA banana NA apple
> 1 2 3 3 2 3 1
>
>value.labels(x) <- c(Apfel=1, Banane=2, Birne=3) # redefine labels
>x
>### desired result
>Apfel Banane Birne Birne Banane Birne Apfel
> 1 2 3 3 2 3 1
>
>value.labels(x) # inspect labels
>### desired result
>Apfel Banane Birne
> 1 2 3
More information about the R-help
mailing list