【问题标题】:Error in R Using SQLDF: too many SQL variablesR 使用 SQLDF 出错:SQL 变量太多
【发布时间】:2017-10-20 02:04:24
【问题描述】:

我有一个大型数据集,在 r 中有近 2000 个变量。然后我使用 sqldf 编写一些案例语句来在原始数据集上创建新列。但是我收到以下错误:

 Error in rsqlite_send_query(conn@ptr, statement) : too many SQL variables

我今天重新启动了我的笔记本电脑,之前这个错误从未发生过。

感谢任何帮助。

【问题讨论】:

  • 你能澄清一下我应该在 r 中输入什么吗?该链接提供信息,但我无法调整最大列数。我试过“SQLITE_MAX_COLUMN”但无济于事
  • 您在 R 中无能为力。您需要从 CRAN 或 github 获取 RSQLite 的源代码,更改 RSQLite 随附的 SQLite C 代码中的 SQLITE_MAX_COLUMN,然后重建包——这将也重建 SQLite。
  • 好的,我从 CRAN 获得了 RSQLite 的包源。我想我已经在“src”中的“sqlite3”文件夹中更改了包的正确部分。然后我将编辑后的文件夹压缩为一个新的 .gz 文件。然后我将它输入到终端“R CMD INSTALL path/RSQLite_1.1-3.tar.gz”并在r中重新安装了包。但仍然没有运气。你能详细说明一下吗?
  • 不是对您问题的回答,而是:无论您使用sqldf 做什么,您都可以在base R 或tidyversedata.table 中执行,限制较少。

标签: r sqldf


【解决方案1】:

我遇到了同样的问题。我只是限制了列数

# here creating data with alot of columns
a<- mtcars
for( i in 1:1000 ){
b <- mtcars
colnames(b) <- paste( colnames(b), i , sep="_")
a <- cbind( b , a )
}

ncol( a )

# I get the error here
sqldf( "Select SUM( wt) as weights from a ")

#so I just limited the columns
z <- a[ , c( "gear","wt")]
# and than this works
sqldf( "Select SUM( wt ) as weights from z ")

【讨论】:

    猜你喜欢
    • 2011-10-29
    • 1970-01-01
    • 2015-03-11
    • 1970-01-01
    • 2015-01-14
    • 2020-07-13
    • 1970-01-01
    • 2011-11-24
    • 1970-01-01
    相关资源
    最近更新 更多