Aan de slagGa gratis aan de slag

Importing data

There are a lot of ways to import data into R! Once the data is imported into R, we need to transform the data into an xts object to help with analysis. These xts objects are so much easier to plot and manipulate.

In this exercise you are going to create a date index and then turn your data into an xts object. Your data has been imported for you into an object called bev.

Deze oefening maakt deel uit van de cursus

Forecasting Product Demand in R

Cursus bekijken

Oefeninstructies

  • Load the xts package using the library() function.

  • Create a date index object called dates that is 176 weeks long starting on Jan, 19, 2014. You will want to use the YYYY-MM-DD format.

  • Create an xts object called bev_xts based on the dates object for your index and the bev object for your data.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Load xts package 
library(___)

# Create the dates object as an index for your xts object
dates <- seq(as.Date("___"), length = ___, by = "___")

# Create an xts object called bev_xts
bev_xts <- xts(___, order.by = ___)
Code bewerken en uitvoeren