Unable to view boxplots using purrr package (R Studio)

Screen Link:
https://app.dataquest.io/m/277/guided-project%3A-analyzing-forest-fire-data/5/why-do-forest-fires-occur-when-they-do

My Code:

library(purrr)
create_boxplot <- function(x, y) {
  ggplot(data = forestfires_month) + 
    aes_string(x = x, y = y) +
    boxplot() +
    theme(panel.background = element_rect(fill = "white"))
} 

x_var_month<- names(create_boxplot_month)[3]
x_var_day<- names(create_boxplot_month)[4]
y_var <- names(create_boxplot_month)[5:12]

month_boxplot<-map2(x_var_month, y_var, create_boxplot)
day_boxplot<-map2(x_var_day, y_var, create_boxplot)

What I expected to happen:
Box plots to appear. But unable to view.

What actually happened:
I am unable to view any box plots on R studio. May I know why?

1 Like

Hello,

I wrote my code like this and was able to visualize the boxplots.

I think you missed the geom_boxplot()

Cheers

create_boxplots <- function(x, y) {
  ggplot(data = forest_fires) + aes_string(x = x, y = y) +
    geom_boxplot() + theme(panel.background = element_rect(fill = 'white'))
}
2 Likes