0

I am trying to code this graph with should be pretty easy, but run into the error "Error: This function should not be called directly" I am pretty sure I have made some mistakes in the aes part...

My goal is to plot a graph for the most growing area (reason why I have filtered) per year. the y should be the number of patents granted, since there is no variable counting such, I would like to use the count of observations.

patents_most <- patents%>%  
 filter(area_30==9)

ggplot(patents_most, aes(x=appl_year, y=count(n())))+
  geom_line()

I am a rookie so forgive me for eventual "stupid" mistakes.

Thank you in advance!!

IMParasharG
  • 1,869
  • 1
  • 15
  • 26
  • 2
    Hi! you should make your code reproducible see here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – RLave Mar 01 '19 at 12:07
  • 3
    It seems that you should add `%>% mutate(y=count())` after `filter`, then proceed with `ggplot()` with `aes(x=appl_year, y=y)` – RLave Mar 01 '19 at 12:08
  • Thank you for your reply! patents_most <- patents%>% filter(area_30==9)%>% mutate(y=count()) ggplot(patents_most, aes(x=appl_year, y=y))+ geom_line() it gives me this error: Error in mutate_impl(.data, dots) : Evaluation error: argument "x" is missing, with no default. – Tommaso Arcangeli Mar 02 '19 at 15:19
  • Hi! please update your question, and post an example of your data. Otherwise we can't help much. – RLave Mar 02 '19 at 15:24
  • I am reading the article but unfortunately I am not sure I am understanding how to do it :/ – Tommaso Arcangeli Mar 02 '19 at 15:26
  • If you can share your data use `dput(patents)`, and paste here the output if it's not too much big. Otherwise `dput(head(patents))` – RLave Mar 02 '19 at 15:31
  • Also try this: `patents_most <- patents%>% filter(area_30==9)%>% mutate(y=count()) %>% ggplot(aes(x=appl_year, y=y))+ geom_line()`. I noticed a few mistakes in your code. – RLave Mar 02 '19 at 15:31

0 Answers0