Guided Project: Forest Fires

Hi, can anyone tell me why my boxplots don’t show the name of the variable (FFMC, DMC etc.) when I run the map2() code, but instead I get the data series values (c(5.1, 6.7,…)?

create_boxplot <- function(x, y) {
ggplot(data = forestfires) +
aes_string(x = x, y = y) +
geom_boxplot()
}

x_var_month <- names(forestfires)[3]
x_var_day <- names(forestfires)[4]
fire_variables <- names(forestfires)[5:12]

map2(x_var_month, fire_variables, create_boxplot)

Hi @akyrtsis1. The code provided above seemed correct to me. For example, this is the chart that was generated for wind.

The other boxplots also looked as expected. Here is the full code script I used in R Studio:

library(readr)
library(ggplot2)
library(purrr)
forestfires <- read_csv("forestfires.csv")

create_boxplot <- function(x, y) {
  ggplot(data = forestfires) +
    aes_string(x = x, y = y) +
    geom_boxplot()
}

x_var_month <- names(forestfires)[3]
x_var_day <- names(forestfires)[4]
fire_variables <- names(forestfires)[5:12]

map2(x_var_month, fire_variables, create_boxplot)