#check_answers(my_answers)

Question

O código abaixo irá criar um gráfico simples com os preços da ação da empresa Engie (EGIE.SA).

library(ggplot2)

df_yf <- yfR::yf_get("EGIE3.SA", 
              first_date = "2018-01-01")

p <- ggplot(
  df_yf,
  aes(x = ref_date, y = price_adjusted)
) + geom_line()

Após a execução do código acima, use as ferramentas de programação do R para testar os seguintes temas da figura:

e lembre de adicionar a informação do tema no título da figura.

Solution

plot_fct <- function(theme_str, p) {

    this_theme <- eval(parse(text = theme_str))
    p <- p + 
      this_theme() +
      labs(title = stringr::str_glue("{theme_str}"))

    return(p)
}

my_themes <- c(
  "ggplot2::theme_light",
  "ggplot2::theme_bw",
  "ggplot2::theme_grey",
  "ggplot2::theme_minimal"
)

l_p <- purrr::map(my_themes, plot_fct, p = p)

cowplot::plot_grid(plotlist = l_p)

Meta-information

extype: string exsolution: r mchoice2string(c(TRUE, FALSE, FALSE, FALSE, FALSE), single = TRUE) exname: "stats 01" exshuffle: TRUE



msperlin/vdr documentation built on Nov. 25, 2022, 2:29 a.m.