How to import .csv file from https URL source into R 3.1.1 or into RStudio in Ubuntu 14.04 LTS and in Windows (64-bit versions)

Posted: 2014/09/17 in Data Science, Ubuntu
Tags: , , , , , , , ,

Prerequisites for all platforms (Windows, Mac OSX and GNU/Linux):

First make sure that R version 3.1.1 is installed.

Prerequisites for Windows:

Install the curl binary for Windows before importing List_P_3D_data.csv.

Windows 64-bit users should run the following .cmd script as administrator:
https://courses.edx.org/courses/KIx/KIexploRx/3T2014/discussion/forum/i4x-kiX-KIexploRx-course-2014_Practicalities/threads/5451f72635c79c749c000906

The previous .cmd script takes care of installing curl,R,RStudio and other applications in Windows. Or you can download curl here:

http://www.confusedbycode.com/curl/

I successfully installed and tested the import using this Windows curl binary:

http://www.confusedbycode.com/curl/curl-7.38.0-win64.msi

Make sure to close RGui, close RStudio and then restart RGui or Rstudio before proceeding with the next steps.

Prerequisites for Fedora 20:

Run following Terminal commands before importing List_P_3D_data.csv:

sudo yum update
sudo yum install curl curl-devel

Prerequisites for Ubuntu 14.04 LTS/Linux Mint:

Run following Terminal commands before importing List_P_3D_data.csv:

sudo apt-get update
sudo apt-get install libcurl4-openssl-dev r-cran-rcurl curl

Then upgrade to newest version of curl using this procedure:

https://mark911.wordpress.com/2015/09/27/how-to-compile-and-install-newest-version-of-curl-from-github-in-ubuntu-14-04-lts-64-bit/

Then run the following commands in R or RStudio:

install.packages("RCurl")

library(RCurl)

URL <- "https://courses.edx.org/c4x/KIx/KIexploRx/asset/List_P_3D_data.csv"

destfile <- "List_P_3D_data.csv"

download.file(URL, destfile = destfile, method = "curl")

a <- read.csv2(destfile)

This approach improves the portability, traceability and the reproducible research quality of the R code…

Leave a comment