I am trying to learn dplyr and I was using nywflights13 package. I was trying to find out proportions of flights from Origin(NYC(EWR,JFK)) to destination(Seattle)
The output I am expecting is,
Origin n Prop
JFK 2092 53
EWR 1831 47
I am able to do it in other ways. But I am trying to find using dplyr package. I tried the following without much success,
library("nycflights13")
flights %>% filter(dest=="SEA") %>% group_by(origin) %>%
summarise(n=n(origin)) %>% mutate(Prop= n / sum(n))
But I am getting an error as Error in n(origin) : unused argument (origin)
Can anybody help me what correction I should do in this?