Error in R Using SQLDF: Too Many SQL Variables

I have a large dataset with almost 2000 variables in r. Then I use sqldf to write several case statements to create new columns in 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 this error has never occurred before.

Any help is appreciated.

+4
source share
1 answer

I ran into 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 ")
+1
source

Source: https://habr.com/ru/post/1666477/


All Articles