[R] upData levels in Hmisc

Frank E Harrell Jr fharrell at virginia.edu
Mon May 19 18:12:58 CEST 2003


On Mon, 19 May 2003 11:50:24 -0400
Tanya Murphy <tmurph6 at po-box.mcgill.ca> wrote:

> Dear listserve members, especially Prof. Harrell:
> 
> I am trying to create a factor variable that has fewer levels than the 
> original.
> 
> I have a factor:
> >rosa$risk1
>    [1] 2 2 5 1 ...
> [1799] 3 3 1 3 1 6 3 3 1 5 3 5 3 3 3 0 3 3 3 1 1 3
> Levels: 0 1 2 3 4 5 6 8
> 
> But when I do this:
> rosa2 <- upData(rosa, 
> levels=list(risk1=list(1='1',2='2',3='3',0=c('0','4','6','8'))))
> 
> I get:
> Error: syntax error
> 
> But I am able to reproduce the dat2 <- upData(dat, etc...)  example in Prof. 
> Harrell's Hmisc notes.
> 
> Thanks!
> 
> Tanya Murphy

In S you can avoid quoting names in vectors and lists when these are legal S names.  Legal names do not start with numbers.  Use e.g. '1'='1', ..., '0'=c('0','4','6','8').
---
Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat




More information about the R-help mailing list