It seems everything is ok if
subset(mdf, id %in% c("A","B"))
but error if
ids = c("A","B")
subset(mdf,id %in% ids)
The following is demo codes:
con1 = dbConnect(dbDriver("MonetDB"),"monetdb://go:50000/voc")
d = data.frame(id=base::sample(c("A","B","C","D"),100,replace=T),v=sample(1:10,100,replace=T),stringsAsFactors=F)
head(d)
str(d)
dbWriteTable(con1, "test", d)
mdf <- monet.frame(con1,"test")
subset(mdf, id %in% c("A","B"))
ids = c("A","B")
subset(mdf,id %in% ids)
MonetDB.R_0.8.0 DBI_0.2-7
R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit)
The subset(mdf, id %in% c("A","B"))
actually translate to sql as:
MonetDB-backed data.frame surrogate
2 columns, 44 rows
Query: SELECT * FROM test WHERE ( (id IN ('A','B')) )
Columns: id (character), v (numeric)
The error message for
IDS = c("A","B")
subset(mdf,id %in% IDS)
is something like:
Error in .local(conn, statement, ...) :
Unable to execute statement 'SELECT COUNT(*) FROM test WHERE ( (id IN 'AB') ) '.
Server says 'syntax error, unexpected STRING, expecting '(' in: "select count(*) from test where ( (id in 'AB'"' [#42000].
I guess it is a MonetDB.R specific issue. Just don't know how to circumvent it.
Thanks.
First of all, thanks for the very good bug report that was generated by cooperation here. I had encountered this issue sometime before, it should be fixed in version 0.8.1 of the package that is available on R-Forge (https://r-forge.r-project.org/R/?group_id=1534).