On Mar 25, 2011, at 8:30 AM, agent dunham wrote:
Dear all,
According to the post I was trying:
factorA = c(2,2,3,3,4,4,3,4,2,2)
levels(factorA <- c("lv1","lv2","lv3") )
Well, this is wrong. Try:
levels(factorA) <- c("lv1","lv2","lv3")
> factorA
[1] 2 2 3 3 4 4 3 4 2 2
attr(,"levels")
[1]
Dear all,
According to the post I was trying:
factorA = c(2,2,3,3,4,4,3,4,2,2)
levels(factorA <- c("lv1","lv2","lv3") )
But this returns NULL and doesn't change factor names.
Actually, my factor is included in a data.frame, so I also tried:
levels(df$factorA)[levels(df$factorA)=="2"] <-
Dear all,
According to the post I was trying:
factorA = c(2,2,3,3,4,4,3,4,2,2)
levels(factor <- c("lv1","lv2","lv3") )
But this returns NULL and doesn't change factor names.
Actually, my factor is included in a data.frame, so I also tried:
levels(df$factorA)[levels(df$factorA)=="2"] <- "lv1
Thank you so much both for the answer. I think I have a better handle
on this now. Yes, Loblolly$Seed is an ordered factor, but I didn't
realize that the default for ordered factor is contr.poly.
And then I was further confused because I didn't realize the
coefficient names generated (not
Hi Saiwing,
If all you are asking is how to rename a factor vector, the easiest way
would be to use:
levels(Loblolly$Seed) <- c( a vector of level names you would like to use
for the factor - separated by commas)
If you are asking how to make your output look better, I am not sure I have
an idea (
Dear Saiwing Yeung,
You appear to be using orthogonal-polynomial contrasts (generated by
contr.poly) for Seed, which suggests that Seed is either an ordered factor
or that you've assigned these contrasts to it. Because Seed has 14 levels,
you end up fitting an degree-13 polynomial. If Seed is inde
6 matches
Mail list logo