This blog post will teach you how to create a ggplot using an open-source dataset called ‘penguings’
# install.packages("palmerpenguins")
library(palmerpenguins)
library(ggplot2)
# let's take a brief look at the dataset using head the head function
head(penguins)
## # A tibble: 6 × 8
## species island bill_length_mm bill_depth_mm flipper_length_… body_mass_g sex
## <fct> <fct> <dbl> <dbl> <int> <int> <fct>
## 1 Adelie Torge… 39.1 18.7 181 3750 male
## 2 Adelie Torge… 39.5 17.4 186 3800 fema…
## 3 Adelie Torge… 40.3 18 195 3250 fema…
## 4 Adelie Torge… NA NA NA NA <NA>
## 5 Adelie Torge… 36.7 19.3 193 3450 fema…
## 6 Adelie Torge… 39.3 20.6 190 3650 male
## # … with 1 more variable: year <int>
# now we can create the plot
ggplot(penguins, aes(bill_length_mm, bill_depth_mm, color = species)) +
geom_point()
## Warning: Removed 2 rows containing missing values (geom_point).