How are these two plots similar?

plot1 <- df_input %>% 
  ggplot(aes(!!sym(df_numeric1_name), !!sym(df_numeric2_name))) +
  geom_point() 

plot2 <- df_input %>% 
  ggplot(aes(!!sym(df_numeric1_name), !!sym(df_numeric2_name))) +
  geom_smooth() 

plot1 + plot2

The geom is different between these plots

geom is short for geometric object, which is the visual object used to represent the data

plot1 <- ggplot(r dataframe_name) +
geom_point(aes(r df_numeric1_name,r df_numeric2_name))

plot2 <- ggplot(r df_numeric1_name,r df_numeric2_name) +
geom_smooth(aes(r df_numeric1_name,r df_numeric2_name))

Choosing your (geom)etries

Different data types require different plot types.

When plotting your data, it is often helpful to take a glimpse at the data you intend to plot to know what kinds of variables you will be working with

glimpse(r dataframe_name)


Geoms

So now that you know your variable types, how do you know what geoms to use??

Use the following resources to match your data type to the appropriate geoms


https://rstudio.com/resources/cheatsheets/


https://www.data-to-viz.com/

Change this scatterplot code to draw boxplots {.smaller}

ggplot(r dataframe_name) + geom_point(aes(x=r df_char1_name,y=r df_numeric1_name))


Use the cheatsheet. Try your best guess.

What will this code do?

ggplot(r dataframe_name) +
geom_boxplot(aes(x=r df_char1_name,y=r df_numeric1_name)) +
geom_point(aes(x=r df_char1_name,y=r df_numeric1_name))

Try including two geoms for yourself


Each new geom adds a new layer



matthewhirschey/bespokelearnr documentation built on Oct. 11, 2020, 12:57 a.m.