Skip to content
Prev 2545 / 398500 Next

lda in R vs S

On Thu, 6 May 1999, Marc R. Feldesman wrote:

            
It will allow factors: they get coerced to integers. I think from the
evidence later that sarich.na[,3] is not a factor, even if it looks like
one.
Of things that look like factors? (I don't know, I didn't write this.)
I am saying that it is legal in S-PLUS but poor style, and likely to cause
methods (e.g. for prediction) to fail. In neither dialect is it what the
designers intended.
Yes, S-PLUS coerces character vars in model frames to factor, and I
believe R does not allow them. Here is a simple experiment.

R:
[1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"     
species <- as.character(iris$Species)
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames,  : invalid variable type
works fine. It looks like R is having problems with data frames here
that I will have to look into. In R a data frame is not a matrix, and
much less coercion gets done.

Brian