LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Practicing Statistics Interview Questions in R

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

library(xts)

# View the structure of gas
str(___)

# Coerce to date class
gas$Date <- ___(gas$Date)
Code bearbeiten und ausführen