Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
library(patchwork)library(tidyquant)
Loading required package: PerformanceAnalytics
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following object is masked from 'package:tsibble':
index
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
######################### Warning from 'xts' package ##########################
# #
# The dplyr lag() function breaks how base R's lag() function is supposed to #
# work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
# source() into this session won't work correctly. #
# #
# Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
# conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
# dplyr from breaking base R's lag() function. #
# #
# Code in packages is not affected. It's protected by R's namespace mechanism #
# Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
# #
###############################################################################
Attaching package: 'xts'
The following objects are masked from 'package:dplyr':
first, last
Attaching package: 'PerformanceAnalytics'
The following object is masked from 'package:fpp3':
prices
The following object is masked from 'package:graphics':
legend
Loading required package: quantmod
Loading required package: TTR
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Attaching package: 'tidyquant'
The following object is masked from 'package:fable':
VAR
aus_accommodation
# A tsibble: 592 x 5 [1Q]
# Key: State [8]
Date State Takings Occupancy CPI
<qtr> <chr> <dbl> <dbl> <dbl>
1 1998 Q1 Australian Capital Territory 24.3 65 67
2 1998 Q2 Australian Capital Territory 22.3 59 67.4
3 1998 Q3 Australian Capital Territory 22.5 58 67.5
4 1998 Q4 Australian Capital Territory 24.4 59 67.8
5 1999 Q1 Australian Capital Territory 23.7 58 67.8
6 1999 Q2 Australian Capital Territory 25.4 61 68.1
7 1999 Q3 Australian Capital Territory 28.2 66 68.7
8 1999 Q4 Australian Capital Territory 25.8 60 69.1
9 2000 Q1 Australian Capital Territory 27.3 60.9 69.7
10 2000 Q2 Australian Capital Territory 30.1 64.7 70.2
# ℹ 582 more rows
aus_accommodation |>distinct(State)
# A tibble: 8 × 1
State
<chr>
1 Australian Capital Territory
2 New South Wales
3 Northern Territory
4 Queensland
5 South Australia
6 Tasmania
7 Victoria
8 Western Australia
tasmania <- aus_accommodation |>filter(State =="Tasmania") |># select(Date, Takings, Occupancy) opción 1: escoger todas manuales# select(Date, Takings:Occupancy) opción 2: date y de takings hasta occupancyselect(-c(State, CPI)) |># opción 3: todas menos state y cpimutate('Año unión Nª1'=1 ) |> janitor::clean_names()tasmania
p <- tasmania |>autoplot(log(takings), color="#F2A7DFFF", size=2) +geom_point()ggplotly(p, dynamicTicks =TRUE) # dynamicTicks permite seleccionar segmento para hacer zoom
tasmania |>gg_season(log(takings)) # para ver la estacionalidad, te grafica cada año
stocks_data |>ggplot(aes(x = date, y = close, color = symbol)) +geom_line()
stocks_data |>ggplot(aes(x = date, open = open, high = high, low = low, close = close)) +geom_candlestick() +facet_wrap(~ symbol, ncol =2)
c(3, 6, 12, 89)
[1] 3 6 12 89
c("pablo", "juan", "maría")
[1] "pablo" "juan" "maría"
c(TRUE, FALSE, FALSE, TRUE)
[1] TRUE FALSE FALSE TRUE
# listas
us_retail_employment <- us_employment |>filter(year(Month) >=1990, Title =="Retail Trade") |>select(-Series_ID)us_retail_employment |>write_csv("empleo_eeuu.csv")
Cedasticidad:
Homocedasticidad: Para varianza constante.
Heterocedasticidad: Para varianza variable.
Componentes:
Estacionalidad: Periodicidad fija.
Ciclos: No se sabe con exactitud cuando va a ser la siguiente.
Tendencia
Se calcula a través de medias móviles.
Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
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:
1+1
[1] 2
You can add options to executable code like this
[1] 4
The echo: false option disables the printing of code (only output is displayed).