Skip to content

Instantly share code, notes, and snippets.

@cimentadaj
Created August 15, 2016 15:12
Show Gist options
  • Save cimentadaj/f6fd1577e8b93e269d8f0ae546e23c54 to your computer and use it in GitHub Desktop.
Save cimentadaj/f6fd1577e8b93e269d8f0ae546e23c54 to your computer and use it in GitHub Desktop.
## Two continuous variables
ggplot(data=housing, aes(x = Home.Value, y= Structure.Cost)) + stat_identity() # Is the same as geom_point()
ggplot(housing, aes(x = Home.Value, y= Structure.Cost, color=region)) + stat_smooth() # Is the same as geom_smooth()
## One continuous and one categorical
ggplot(data=housing, aes(x = region, y= Home.Value)) + stat_boxplot() # Is the same as geom_boxplot()
ggplot(housing, aes(x = region, y= Structure.Cost, color=region)) + stat_ydensity() # Is the same as geom_violin()
## One categorical
ggplot(data=housing, aes(x = region)) + stat_count() # Is the same as geom_bar()
## One continuous
ggplot(data=housing, aes(x = Home.Value)) + stat_bin() # Is the same as geom_histogram()
ggplot(data=housing, aes(x = Home.Value)) + stat_density() # Is the same as geom_density()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment