2

似乎一切都好,如果

subset(mdf, id %in% c("A","B"))

但如果错误

ids = c("A","B")
subset(mdf,id %in% ids)

以下是演示代码:

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 版本 3.0.2 (2013-09-25) 平台:x86_64-pc-linux-gnu (64-bit)

subset(mdf, id %in% c("A","B"))实际转换为 sql 为:

MonetDB-backed data.frame surrogate
2 columns, 44 rows
Query: SELECT * FROM test WHERE ( (id IN ('A','B')) ) 
Columns: id (character), v (numeric)

错误消息 IDS = c("A","B") subset(mdf,id %in% IDS)

是这样的:

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].

我猜这是MonetDB.R的特定问题。只是不知道如何规避它。

谢谢。

4

1 回答 1

3

首先,感谢这里合作生成的非常好的错误报告。我之前遇到过这个问题,它应该在 R-Forge ( https://r-forge.r-project.org/R/?group_id=1534 ) 上可用的包的 0.8.1 版本中得到修复。

于 2013-11-27T07:45:46.017 回答