注意:csv数据“,”后面的空格也会被算入新的字段,","前后不要有空格。
读取csv文件加载为dataframe:
df <- read.csv('play.csv', header = TRUE, sep = ",")查看内容:
> df
Outlook Temperature Humidity Windy Play
1 sunny hot high FALSE no
2 sunny hot high TRUE no
3 overcast hot high FALSE yes
4 rainy mild high FALSE yes
5 rainy cool normal FALSE yes
6 rainy cool normal TRUE no
7 overcast cool normal TRUE yes
8 sunny mild high FALSE no
9 sunny cool normal FALSE yes
10 rainy mild normal FALSE yes
11 sunny mild normal TRUE yes
12 overcast mild high TRUE yes
13 overcast hot normal FALSE yes
14 rainy mild high TRUE no将dataframe写入csv文件中:
write.csv(df, file = "result.csv")
9399

被折叠的 条评论
为什么被折叠?



