0

When i use ggplot without dplyr I can simply write something along the lines of:

ggplot(fulldata,aes(x=FLYTT))+geom_bar()+coord_flip()

The intuitive way of combining dplyr with ggplot for me would be to write:

fulldata%>%ggplot(,aes(x=FLYTT))+geom_bar()+coord_flip()

Since according to the logic in dplyr, the data argument should not have to be explicitly stated.

When I write this, however, the program throws an error since it can't find the missing x aesthetic.

To rectify this, I have to write:

fulldata%>%ggplot(.,aes(x=FLYTT))+geom_bar()+coord_flip()

What does the "." mean in this context and why won't the code work without it?

Magnus
  • 728
  • 4
  • 17
  • 2
    Remove comma, it should work fine. `mtcars %>% ggplot(aes(x = cyl)) + geom_bar()` – zx8754 Nov 06 '19 at 10:01
  • Thanks! Do you have any idea of what the period means though? I'm trying to get a better understanding of the syntax. – Magnus Nov 06 '19 at 10:05
  • See [here](https://stackoverflow.com/questions/35272457/what-does-the-dplyr-period-character-reference) for dot meaning. (Possible duplicate). – zx8754 Nov 06 '19 at 10:06

1 Answers1

1

No, you don't need to use ., just like this

fulldata %>% ggplot(aes(x=FLYTT))+geom_bar()+coord_flip()

Nuclear03020704
  • 549
  • 9
  • 22