Quantcast
Viewing all articles
Browse latest Browse all 206430

Filtering in dplyr based on two non-numeric values

I am filtering a dataset and this chunk works fine:

    dwell <- rail %>% 
  filter_(Measure == "Average Terminal Dwell Time (Excluding Cars on Run Through Trains) (Hours)",
         Variable == "System") %>% 
  gather(Date, Hrs, -("railroad":"Sub-Variable"))

But I want to run the following code, adding a second option under variable:

dwell <- rail %>% 
  filter_(Measure == "Average Terminal Dwell Time (Excluding Cars on Run Through Trains) (Hours)",
         Variable == "System"& "System (U.S.)") %>% 
  gather(Date, Hrs, -("railroad":"Sub-Variable"))

But when I do this I get the folloing error: "operations are possible only for numeric, logical or complex types." I have tried swapping the & for | and that didn't work either. I feel like this is going to be a simple switch once someone tells me. Thanks!


Viewing all articles
Browse latest Browse all 206430

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>