1

I want to filter a column in a dataframe which is weather condition line rainy, clear... and contains characters.

` min1$Rainy <- filter(min1$Conditions == "Light Rain")`

I tried the codes above but I faced to this error:

Error in UseMethod("filter_") : no applicable method for 'filter_' applied to an object of class "logical"

How can I solve it? Appreciate for your time.

Shaido
  • 27,497
  • 23
  • 70
  • 73
Negar
  • 21
  • 1
  • 1
  • 6
  • 1
    Welcome to StackOverflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). This will make it much easier for others to help you. – Jaap Oct 16 '17 at 12:12
  • `min1$Rainy` is a column while `filter` produces a dataframe, so how do you want to store a dataframe into a column? – acylam Oct 16 '17 at 15:09

1 Answers1

4

As filter is part of the tidyverse family, it follows the standard tidyverse interface. The first argument needs to be a tbl_df (data frame).

Alex Gold
  • 335
  • 1
  • 9
  • How can I do that? Can you explain more please? – Negar Oct 16 '17 at 12:15
  • `min1 <- filter(min1, Conditions == "Light Rain") `. If you just want the Rainy column, `Rainy <- filter(min1, Conditions == "Light Rain") %>% pull(Rainy)` – Alex Gold Oct 16 '17 at 12:16
  • Could you please tell me how I can write a code to filter more than one Condition? I don't know the correct form of command. For instance, something like this: Rain <- filter(dataframe, Conditions == "Light Rain" & "Light Rain Showers") – Negar Oct 21 '17 at 11:52
  • `Rain <- filter(dataframe, Conditions == "Light Rain" | Conditions == "Light Rain Showers")` – Alex Gold Oct 23 '17 at 11:34