ComenzarEmpieza gratis

Time series object

Many companies gather time-dependent data to look for trends or seasonal variations. As time is irregular, wrangling time-dependent data might be hard, especially in a stressful setting, such as a job interview.

Coercing data to a time series object makes it easier to analyze such datasets.

The xts object takes the following arguments:

  • x - a set of values,
  • order.by - a set of corresponding dates (which need to be of the Date class).

In this exercise, you will work with natural gas prices. The dataset contains two variables:

  • Price - numerical values,
  • Date - dates stored as factors.

The gas dataset is available in your environment.

Este ejercicio forma parte del curso

Practicing Statistics Interview Questions in R

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

library(xts)

# View the structure of gas
str(___)

# Coerce to date class
gas$Date <- ___(gas$Date)
Editar y ejecutar código