[R] How to represent a metric categorical variable?

From: Heinz Tuechler <tuechler_at_gmx.at>
Date: Thu 18 May 2006 - 18:41:34 EST


Dear All,

often I encounter variables, which have only few distinct values and an inherent metric. An example would be a risk score, which classifies patients in several groups like "low, intermediate, high, extreme" with corresponding risk estimates of "0, 1, 2, 5.5". In some cases, like tables and box-plots this score should be treated like a factor, in other cases like cox-regression it should be treated like a numeric variable.

Is there a convenient way to represent a variable like this?

The crucial point is that the variable should retain its numerical values and its value labels. Without value labels it could be defined as factor and used or directly or by as.numeric(), because the levels still represent the numerical values, but as soon as labels are used, the original numerical values get lost.

Thanks,

Heinz Tüchler



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 18 18:49:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 18 May 2006 - 20:10:13 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.