Using the iris dataset as an example, I understand to perform LDA, you can use this
library(MASS)
iris[1:4] <- scale(iris[1:4])
sample <- sample(c(TRUE, FALSE), nrow(iris), replace=TRUE, prob=c(0.7,0.3))
train <- iris[sample, ]
test <- iris[!sample, ]
model <- lda(Species~., data=train)
#view model output
model
and it will return the group means, coefficient of linear discrimants and proportion of trace.
However, is there a way to extract the coefficient of linear discriminant into a dataframe?
CodePudding user response:
you can checkout the whole data strucutre with str(model)
and with model$scaling
you can get the data.frame with the linear discriminants