6
data <- read.delim("C:\\test.txt", header = FALSE, sep = "$$$$$")
Error in scan(file, what = "", sep = sep, quote = quote, nlines = 1, quiet = TRUE,  : 
  invalid 'sep' value: must be one byte

为什么会有这样的限制?我能克服吗?

4

1 回答 1

5

这是一个潜在的解决方案。

假设这是您文件中的行的样子

1$$$$$2$$$$$3$$$$$4

下面将创建一个矩阵,其中变量存储为字符。

do.call(rbind,strsplit(readLines('test.txt'),'$$$$$',fixed=T))
于 2010-04-28T22:23:31.183 回答