공유자료 HOME > 자료실 > 공유자료
 
[정보기술활용연구] R로 하는 판별분석 code
관리자 16-06-07 08:37 1,553
library(car)
# install.packages('rattle')
data(wine, package='rattle')
attach(wine)
head(wine)
scatterplotMatrix(wine[2:6])
 
library(MASS)
wine.lda <- lda(Type ~ ., data=wine)
wine.lda
wine.lda.values <- predict(wine.lda)
ldahist(data = wine.lda.values$x[,1], g=Type)
ldahist(data = wine.lda.values$x[,2], g=Type)
plot(wine.lda.values$x[,1],wine.lda.values$x[,2]) # make a scatterplot
text(wine.lda.values$x[,1],wine.lda.values$x[,2],Type,cex=0.7,pos=4,col="red") # add labels