Re: [R] factor, as.factor and levels

2009-04-08 Thread Heinz Tuechler
Jim - you are right, I should have looked before. So there is a difference that should also effect the dropping of unused levels. Thanks, Heinz At 15:31 08.04.2009, jim holtman wrote: It is just a simple version of 'factor'. The only speed advantage it might have is that it checks to see if

Re: [R] factor, as.factor and levels

2009-04-08 Thread jim holtman
It is just a simple version of 'factor'. The only speed advantage it might have is that it checks to see if it is a factor first. Here is the definition: )> as.factor function (x) if (is.factor(x)) x else factor(x) You can always list out what the function does to get a better understanding of

Re: [R] factor, as.factor and levels

2009-04-08 Thread Heinz Tuechler
Thank you, Jim. I see, the fact that in the documentation you find only "as.factor(x)" means that it does not accept more arguments. Does as.factor have speed advantages over factor, or is there a different cause for it's existence? Heinz At 13:50 08.04.2009, jim holtman wrote: as.factor do

Re: [R] factor, as.factor and levels

2009-04-08 Thread jim holtman
as.factor does not accept levels as an argument. use the first form that you have factor(ch1, levels=ch1) On Wed, Apr 8, 2009 at 7:36 AM, Heinz Tuechler wrote: > Dear All, > > to my surprise as.factor does not accept a levels argument. Maybe I did not > read the documentation well enough. See

[R] factor, as.factor and levels

2009-04-08 Thread Heinz Tuechler
Dear All, to my surprise as.factor does not accept a levels argument. Maybe I did not read the documentation well enough. See the example below. I wanted to use ch1 as factor in the newdata argument of survfit, so I assumed that I could write as.factor(ch1, levels=ch1), since the order should