library(rattle) rattle() x
x[50:60] #matrix
y<-matrix(1:6,nrow=2) ?matrix ??matrix
y<-matrix(1:6,nrow=2,byrow=TRUE) set.seed(42)
x<-rnorm(100,mean=1,sd=2)
??students x=rt(400, 6)
matrix(x,nrow=100)
#Input data. 导入CSV格式数据
weather<-read.csv(\"d:\\\\weather.csv\") weather
head(weather) tail(weather)
str(weather) #数据结构 weather$RainTomorrow
table(weather$RainTomorrow) summary(weather$RainTomorrow) summary(weather$MinTemp) mean(weather$MinTemp) var(weather$MinTemp) sd(weather$MinTemp)
table(weather$RainToday,weather$RainTomorrow)
#画图
plot(weather$MinTemp)
plot(weather$MinTemp,type=\"l\")
plot(as.Date(weather$Date),weather$MinTemp,type=\"l\") plot(table(weather$RainToday,weather$RainTomorrow)) barplot(table(weather$RainTomorrow))
hist(weather$Pressure3pm) #气压柱状(直方)图
plot(density(weather$Pressure3pm)) #气压密度函数图
boxplot(weather$RainTomorrow,weather$Pressure3pm) #气压和明天下雨的关系
boxplot(weather$Pressure3pm) #气压的盒壮图 #model.建模
plot(weather$Pressure3pm,weather$MinTemp)
cor(weather$Pressure3pm,weather$MinTemp) #相关系数
weatherLM<-lm(weather$MinTemp ~ weather$Pressure3pm) #一元线型回归模型 summary(weatherLM)
library(lattice)
xyplot(weather$MinTemp ~
weather$Pressure3pm,type=c(\"p\
在聚类程序后添加:
weatherKMEANS$model$center
决策树:
导入数据,选model,执行即可
(可用于判断是否疏解),点draw画出决策树
因篇幅问题不能全部显示,请点此查看更多更全内容