I have a dataframe :
df <- data.frame( Date = c("2017-02-23", "2017-02-23", "2017-02-24", "2017-02-24", "2017-02-25", "2017-02-25", "2017-02-25"),
var = c(2, NA, 1, 1,1, 7, 4))
I want to filter by date where var == 7
I tried with:
df %>% filter(Date[var == 7])
But there is an error: Argument 2 filter condition does not evaluate to a logical vector
What is wrong with this code?
答案 0 :(得分:0)
You can use dplyr
package
> df %>% filter(var == 7)
Date var
1 2017-02-25 7