R读写文件,我用得最多的就是csv格式文件。

读文件举例如下(D:\temp\1.csv):
enter image description here

示例代码如下:

> myData = read.table(file = "d://temp/1.csv", sep = ",")
> myData
  V1 V2 V3 V4 V5
1  1  2  3  4  5
2  6  7  8  9 10
3 11 12 13 14 15
> mode(myData)
[1] "list"
> length(myData)
[1] 5
> myData$V1
[1]  1  6 11
>

或者直接:

myData = read.csv(file = "d://temp/1.csv")

写文件示例代码:

write.table(list("A", "B", "C", "D", "E"), file = "d://temp/1.csv", append = TRUE, quote = FALSE, sep = ",", row.names = FALSE, col.names = FALSE)

结果:
enter image description here

时间煮雨,去听吧,有点忧伤,跟今天的心境一样......

#stats# enter image description here