我想将参数 ( stringsAsFactors=FALSE) 传递给rbindin do.call。但以下不起作用:
data <- do.call(rbind,
strsplit(readLines("/home/jianfezhang/adoption.txt"), split="\t#\t"),
args=list(stringsAsFactors=FALSE))
我想将参数 ( stringsAsFactors=FALSE) 传递给rbindin do.call。但以下不起作用:
data <- do.call(rbind,
strsplit(readLines("/home/jianfezhang/adoption.txt"), split="\t#\t"),
args=list(stringsAsFactors=FALSE))
do.call(rbind.data.frame, c(list(iris), list(iris), stringsAsFactors=FALSE))
如果不是因为rbind不知道该怎么做stringsAsFactors(但cbind.data.frame会),那将是我的答案。
的输出strsplit可能是一个向量列表,在这种情况下rbind会创建一个矩阵。您可以指定stringsAsFactors何时将此矩阵转换为 data.frame,
data.frame(do.call(rbind, list(1:10, letters[1:10])), stringsAsFactors=FALSE)
Alternatively, you can set stringsAsFactors to FALSE globally using options:
options(stringsAsFactors=FALSE)
Setting this at the top of the script will enforce this throughout the script. You could even add to .Rprofile to set this option for the all the R sessions you open.
我不确定您的函数调用是否有效,但试试这个:
data <- do.call(rbind,
c(strsplit(readLines("/home/jianfezhang/adoption.txt"),split="\t#\t"),
list(stringsAsFactors=FALSE))
您需要do.call通过一个列表将所有参数传递给。您可以通过以下方式连接两个列表c
> c(list(1, 2), list(3, 4))
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 3
[[4]]
[1] 4