library(tidyverse)
library(fpp3)Mi primer documento Quarto
Running Code
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
Acciones
gafa_stockgafa_stock|>
autoplot(Close)+
facet_wrap(~ Symbol,scales="free_y",ncol=2) theme(legend.position="none")List of 1
$ legend.position: chr "none"
- attr(*, "class")= chr [1:2] "theme" "gg"
- attr(*, "complete")= logi FALSE
- attr(*, "validate")= logi TRUE
gafa_stock|>
#Pasar las columnas a filas
pivot_longer(cols=-c(Symbol,Date),names_to = "tipo", values_to="valor") |>
#Combertir a tibble
as_tibble()|>
#Agrupar por accion y tipo de var
group_by(Symbol,tipo) |>
#Sacar la media por grupos
summarise(media=mean(valor))|>
#pasar los tipos a columnas
pivot_wider(names_from = tipo, values_from=media)`summarise()` has grouped output by 'Symbol'. You can override using the
`.groups` argument.