I'm studying the main functions of dplyr
package. When I type flights
I have it:
year month day dep_time sched_dep_time dep_delay
<int> <int> <int> <int> <int> <dbl>
1 2013 1 1 517 515 2
2 2013 1 1 533 529 4
3 2013 1 1 542 540 2
4 2013 1 1 544 545 -1
5 2013 1 1 554 600 -6
6 2013 1 1 554 558 -4
7 2013 1 1 555 600 -5
8 2013 1 1 557 600 -3
9 2013 1 1 557 600 -3
10 2013 1 1 558 600 -2
we can see day
is a column name. When I type:
jan1 <- filter (flights, month == 1, day==1)
I get the error message
Error in match.arg(method) : object 'day' not found
But it is a column name. Could you help me?
i think you may have a different package loaded that also defines filter
because
library(nycflights13)
filter(flights, month==1, day==2)
works for me.
Can you explicitly use dplyr::filter
and see if it works then ?
dplyr::filter(flights, month==1, day==2)
Try this:
library(dplyr)
df <- tbl_df(data.frame(year = sample(2000:2017,10,replace = T),month = sample(1:12,10,replace = T),day = sample(1:31,10,replace = T)))
may3 <- filter(df,month == 5) %>% filter(day == 3)
or
may3 <- filter(df,month == 5 & day == 3)
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