Hello looking for help:
Say I have a list of the items
my.list <- read.csv("~/R/Work Stuff/Data/Read.csv")
After read.csv –
Item
1 ItemA
2 ItemB
3 ItemC
Now I want to create a new vector MPP.Item which is essentially my list of items which I want to use as a filter condition to filter other data set.
MPP.Item=c(my.list)
MPP %>% filter(Item %in% MPP.Item)
However, it is not working. If I am manually creating it as a vector say:
my.list2 <- c("ItemA", "ItemB", "ItemC")
Works fine
Thanks for your advises
>Solution :
my.list is a dataframe, extract the vector from it.
library(dplyr)
MPP.Item = my.list$Item
MPP %>% filter(Item %in% MPP.Item)
#Without using additional variable `MPP.Item`.
#MPP %>% filter(Item %in% my.list$Item)