Somehow the mail system garbled my last sentence.
It should read:
You want to call 'factor' on the result of the call to 'c'.
Pat
Patrick Burns wrote:
'c' does not have a method for factors. If you were
to try implementing one, you would probably quickly
figure out why not.
You want to call
'c' does not have a method for factors. If you were
to try implementing one, you would probably quickly
figure out why not.
You want to call 'call' factor on the result of the call
to 'c'.
Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Gu
I have found that factor vectors are shy beasts.
Consider:
> empty <- factor(levels=c("eins", "zwei"))
> value <- factor("eins", levels=c("eins", "zwei"))
> c(empty, value)
[1] 1
> empty[1] <- value
> empty
[1] eins
Levels: eins zwei
>
I could not exactly predict this behaviour, but ?c says:
Gavin Simpson <[EMAIL PROTECTED]> [Sun, Jul 13, 2008 at 08:18:37PM CEST]:
> On Sun, 2008-07-13 at 18:47 +0200, Johannes Huesing wrote:
[...]
> > as.factor(c("eins", "zwei", "drei"))[FALSE]
> > does the job but looks a bit weird.
> >
[...]
> > factor(levels = c("one","two","three"))
> factor(0)
>
On Sun, 2008-07-13 at 18:47 +0200, Johannes Huesing wrote:
> What is the least surprising way of initializing a factor with
> predefined levels and with length 0?
> as.factor(c("eins", "zwei", "drei"))[FALSE]
> does the job but looks a bit weird.
>
Notice that one does not need to specify any
5 matches
Mail list logo