[R] How to call a value labels attribute?

Martin Maechler maechler at stat.math.ethz.ch
Sat Jun 3 14:12:12 CEST 2006


>>>>> "Heinz" == Heinz Tuechler <tuechler at gmx.at>
>>>>>     on Tue, 23 May 2006 01:17:21 +0100 writes:

    Heinz> Dear All, after searching on CRAN I got the
    Heinz> impression that there is no standard way in R to
    Heinz> label values of a numerical variable.  

Hmm, there's  names(.)  and  "names(.) <- .."
Why are those not sufficient?

x <- 1:3
names(x) <- c("apple", "banana", NA)


    Heinz> Since this
    Heinz> would be useful for me I intend to create such an
    Heinz> attribute, at the moment for my personal use.  Still
    Heinz> I would like to choose a name which does not conflict
    Heinz> with names of commonly used attributes.

    Heinz> Would value.labels or vallabs create conflicts?

    Heinz> The attribute should be structured as data.frame with
    Heinz> two columns, levels (numeric) and labels
    Heinz> (character). These could then also be used to
    Heinz> transform from numeric to factor. If the attribute is
    Heinz> copied to the factor variable it could also serve to
    Heinz> retransform the factor to the original numerical
    Heinz> variable.

    Heinz> Comments? Ideas?

    Heinz> Thanks

    Heinz> Heinz Tüchler

    Heinz> ______________________________________________
    Heinz> R-help at stat.math.ethz.ch mailing list
    Heinz> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE
    Heinz> do read the posting guide!
    Heinz> http://www.R-project.org/posting-guide.html



More information about the R-help mailing list