问题
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