LoslegenKostenlos loslegen

Import text files in other formats

The previous exercise taught you how to import well-formatted CSV data using getSymbols(). Unfortunately, most data are not well-formatted.

The zoo package provides several functions to import text files as zoo objects. The main function is read.zoo(), which wraps read.table(). The xts class extends zoo, so you can easily convert the result of read.zoo() into an xts object by using as.xts().

In this exercise, you will learn how you can use read.zoo() to import the same AMZN.csv data from the previous exercise.

Diese Übung ist Teil des Kurses

Importing and Managing Financial Data in R

Kurs anzeigen

Anleitung zur Übung

  • Use read.zoo() to import AMZN.csv. Assign the output to an object named amzn_zoo.
  • Convert amzn_zoo to an xts object. Assign the output to an object named amzn_xts.
  • Look at the first few rows of amzn_xts.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Import the AMZN.csv file using read.zoo
amzn_zoo <- read.zoo("___", sep = "___", header = ___)

# Convert to xts


# Look at the first few rows of amzn_xts
Code bearbeiten und ausführen