-1

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?

s157
  • 453
  • 4
  • 10

1 Answers1

0

You can use dplyr package

> df %>% filter(var == 7)

        Date  var
 1 2017-02-25   7
RobJan
  • 1,351
  • 1
  • 14
  • 18
  • I would like to have all rows with that date. I think I´ve got it: df %>% filter(Date %in% Date[var == 7]) – s157 May 31 '19 at 11:55