在R语言中使用read.table()读入CSV文件的数据。
1、假定有score.csv文件
ID,score1,score2,Gender
101,11.35321,0.2,male
102,12.58654,0.6,male
103,19.7938,0.9,female
104,12.01352,0.4,female
105,11.97081,0.4,female
106,17.3748,0.7,female
107,14.24884,0.3,female
108,18.47972,0.8,male
109,18.74792,0.8,male
110,18.90146,0.7,male
2、第一行为标题,其他各行为数据,读入到R工作空间中
> score<-read.table("E:\\Work\\lunwen\\score.csv",header=TRUE,sep=',')
3、检查是否导入正常
> score
ID score1 score2 Gender
1 101 11.35321 0.2 male
2 102 12.58654 0.6 male
3 103 19.79380 0.9 female
4 104 12.01352 0.4 female
5 105 11.97081 0.4 female
6 106 17.37480 0.7 female
7 107 14.24884 0.3 female
8 108 18.47972 0.8 male
9 109 18.74792 0.8 male
10 110 18.90146 0.7 male
如果觉得《R语言-read.table读CSV文件数据》对你有帮助,请点赞、收藏,并留下你的观点哦!