How can I select all the rows of those IDs, that have at least one B as Item?
df<-cbind(c(1,1,1,1,1,2,2,2,2,3,3),c("A","A","B","A","A","B","A","A","B","A","A"))
colnames(df)<-cbind("ID","ITEM")
df
How can I select all the rows of those IDs, that have at least one B as Item?
df<-cbind(c(1,1,1,1,1,2,2,2,2,3,3),c("A","A","B","A","A","B","A","A","B","A","A"))
colnames(df)<-cbind("ID","ITEM")
df
Not sure if this is what you mean, but:
df[df[, 2]=="B", ]
Its easy if you construct a data frame rather than working with a list.
library(dplyr)
df<-data.frame(ID = c(1,1,1,1,1,2,2,2,2,3,3),ITEM=c("A","A","B","A","A","B","A","A","B","A","A"));
df %>% filter(ITEM == "B");