なら大丈夫そうです
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 ビット)
実際には次の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固有の問題だと思います。それを回避する方法がわからないだけです。
ありがとう。