0

I was instructed by the book Analyzing Financial Data and Implementing Financial Models Using R (Clifford S. Ang 2015, chapter 8) to download the USA real GDP data from IMF website https://www.imf.org/en/home. The downloaded file is a .xls, and I converted it to .csv under the name "USRGDP IMF WEO.csv" as instructed.

Then, when I ran the codes on R, the numeric data in the .csv file reversed itself, with semicolons appeared. Illustration is as below:

  1. The original file's number format (when opened by Excel):

    enter image description here

  2. The code:

    library(quantmod)
    us.rgdp <- read.csv("USRGDP IMF WEO.csv", header = FALSE)
    
  3. The output:

    enter image description here

What can be done to fix the data? Thank you, from a beginner to R.

r2evans
  • 141,215
  • 6
  • 77
  • 149

1 Answers1

0

I usually have much more consistent and speedier results using data.table::fread() function. It works for zipped files too.

d3hero23
  • 380
  • 1
  • 12