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
geom
is different between these plotsgeom
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))
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)
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/
ggplot(
r dataframe_name) + geom_point(aes(x=
r df_char1_name,y=
r df_numeric1_name))
Use the cheatsheet. Try your best guess.
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))
geoms
for yourselfEach new geom adds a new layer
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.