dplyr
filter not working when I have a list subsetting in the check Value.
Samething works when I assign to to variable. See code below
df1<-data.frame(x=1:26, y=letters, stringsAsFactors = F)
templist<-list(alpha=df1)
res<-df1 %>% filter(y %in% templist$alpha$y)
nrow(res)
[1] 0
tempLetters <- templist$alpha$y
res<-df1 %>% filter(y %in% tempLetters)
nrow(res)
[1] 26
I thought this used to work earlier. Please help. Note that the column names are same in both (y) by design.
I have updated dplyr
, tidyr
, pipeR
to the latest versions on cran just now (4 jan, 2017)
Of course, dplyr has 'filter()' function to do such filtering, but there is even more. With dplyr you can do the kind of filtering, which could be hard to perform or complicated to construct with tools like SQL and traditional BI tools, in such a simple and more intuitive way.
In this, first, pass your dataframe object to the filter function, then in the condition parameter write the column name in which you want to filter multiple values then put the %in% operator, and then pass a vector containing all the string values which you want in the result.
You can use the following basic syntax in dplyr to filter for rows in a data frame that are not in a list of values: df %>% filter(! col_name %in% c('value1', 'value2', 'value3', ...))
@hadleywickham has confirmed that this is a known bug fixed in dev
Pls see his response on twitter at: https://twitter.com/gunapemmaraju/status/816639470166544384
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With