rmarkdown
Write inline R code using backtick quotes:
forecast()
.
x > 1
## Error in eval(expr, envir, enclos): object 'x' not found
See Hong, Pinson, and Fan (2014).
library(fpp3)
# Load the Victorian electricity demand data from fpp3
data <- vic_elec
# Aggregate data by daily demand
daily_elec <- data %>%
index_by(Date = as_date(Time)) %>%
summarise(DailyDemand = sum(Demand))
# View the first few rows of the aggregated data
head(daily_elec)
## # A tsibble: 6 x 2 [1D]
## Date DailyDemand
## <date> <dbl>
## 1 2012-01-01 222438.
## 2 2012-01-02 257965.
## 3 2012-01-03 267099.
## 4 2012-01-04 222742.
## 5 2012-01-05 210585.
## 6 2012-01-06 210247.
autoplot(daily_elec, DailyDemand) + ggtitle("Daily Electricity Demand in Victoria") +
xlab("Date") + ylab("Electricity Demand (MW)")
You can use interactive plots for if you output html documents.
knitr::kable(head(iris))
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
library(forecast)
library(ggplot2)
autoplot(AirPassengers)