1.cor() 函数,求相关系数。
例:>cor(noodles2[,-1]) #圆括号中指定数据,若包含非数值的列则会在执行时报错。
>noodles %>% select (-date) %>% cor #管道执行,负号表示忽略该列。
2.lm() 函数,执行线性回归分析。括号中是指定模型方程和数据。
例:>icecream<-read.csv("icecream.csv")
>ice.lm<-lm(销售量~气温,data=icecream)
>ice.lm #求斜率和截距
>summary(ice.lm) #求出判定系数以及零假设“斜率为0”的检验结果
3.select() 函数,进行变量的筛选
例:>icecream %>% select(气温,销售量) %>% plot
4.fliter()