Error in R Using SQLDF: too many SQL variables

五迷三道 提交于 2019-12-10 16:48:59

问题


I have a large dataset with nearly 2000 variables in r. I then use sqldf to write a few case statements to create new columns on the original dataset. However I get the following error:

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

I rebooted my laptop today and previously this error never occured.

Any help is appreciated.


回答1:


I hit the same problem. I just limited the number of columns

# 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 ")


来源:https://stackoverflow.com/questions/41586868/error-in-r-using-sqldf-too-many-sql-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!