R语言基础语法
https://zhuanlan.zhihu.com/p/21597713
https://zhuanlan.zhihu.com/p/21576354
1.list转化为data frame
mydataframe=as.data.frame(mylist)
R语言&机器学习
caret package
1.数据划分
对spam这个数据集进行训练集及测试集的8/2划分。
# createDataPartition( )就是数据划分函数
# 对象是spam$type(即spam的type列作为label)
# p=0.8表示训练集所占的比例为80%
# list是输出结果的格式,默认list=FALSE
inTrain <- createDataPartition(y=spam$type,p=0.8,list=FALSE)