[R] How to represent a metric categorical variable?

Heinz Tuechler tuechler at gmx.at
Thu May 18 10:41:34 CEST 2006


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




More information about the R-help mailing list