Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in R Using SQLDF: too many SQL variables

Tags:

r

sqldf

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.

like image 616
greeny Avatar asked Nov 08 '22 03:11

greeny


1 Answers

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 ")
like image 97
MatthewR Avatar answered Nov 15 '22 08:11

MatthewR