a case
df=data.frame(id=c(101,102,102,103,104,104,104),
calmonth=c('01','01','01','01','01','01','02'),
product=c('apple','apple','htc','htc','apple','htc','nokia'),
bb=sample(1:20,7))
> df
id calmonth product bb
1 101 01 apple 4
2 102 01 apple 9
3 102 01 htc 8
4 103 01 htc 5
5 104 01 apple 16
6 104 01 htc 19
7 104 02 nokia 20
sql语句:当calmonth =“01”时,获取id同时使用产品“apple”和产品“htc”的交集
select id from df where calmonth='01' and product="apple" and id in
(select id from df where product="htc" and calmonth="01")
预测结果
id calmonth product
1 102 01 apple & htc
2 104 01 apple & htc
那么响应的 R 语句是什么?