R:相当于 read.dbf 中的 "stringsAsFactors"参数

标签 r

我正在使用“foreign”包读取大型 dbf 文件:

library(foreign)
indata = read.dbf("filepath/filename.dbf")

问题在于,这是将所有变量读入因子。通常的 read.table 命令具有“stringsAsFactors = F”参数来缓解这种情况。是否有任何相当于读取 dbf 文件的方法?

最佳答案

是的,它被捆绑到“as.is”中,请参阅help(read.dbf)

例如:

library(foreign)
x <- read.dbf(system.file("files/sids.dbf", package="foreign")[1])
any(sapply(x, is.factor))
[1] TRUE

y <- read.dbf(system.file("files/sids.dbf", package="foreign")[1], as.is = TRUE)
any(sapply(y, is.factor))
[1] FALSE

关于R:相当于 read.dbf 中的 "stringsAsFactors"参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6578998/

相关文章:

r - "Formal argument "foo "matched by multiple arguments"- 如何在 R 中处理这个?

r - 在 R 中使用 quantstrat/blotter 中的 addDiv(command)

r - R中的累积排名第n项

R dplyr : dealing with NA values and empty/missing rows when summarizing data by group

r - 填充数据框中的特定列

r - 防止 Gillespie SSA 随机模型运行为负值

r - 在 R 版本 3.5.0 中安装 arcgisbinding 包,收到警告 : as ‘lib’ is unspecified, 包 ‘‘arcgisbinding’ 不可用

r - 生成移位的 t 分布数和非中心参数?

r - 使用 tabplot 包时此错误 "Error in if (any(B < 1)) stop("B 太小")"的含义是什么

如果工作日位于日期范围之间,R data.table 将使用逻辑值设置新列