StupidBeauty
Read times:1564Posted at: - no title specified

转载 [ 转载 ]R 语言读入数据

使用scan()函数,可将某个文件中以空格分隔的数值序列读入到一个向量中去。

http://blog.sciencenet.cn/blog-793574-620733.html

亮点

1.5    使用 scan() 命令

read.table() read.fwf() 都是通过调用 scan() 来实现的。在某些时候直接使用 scan() 可以更快速的读取数据。

比如读入一个 200*2000 的数值矩阵可以采用:

mymatrix <- matrix(scan("matrix.dat", n = 200*2000), 200, 2000, byrow = TRUE)

如果用 read.table() 那么其命令为:

mymatrix <- as.matrix(read.table("matrix.dat"))

Your opinions

Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands