Skip to content

Instantly share code, notes, and snippets.

@duxan
Created June 20, 2015 12:21
Show Gist options
  • Save duxan/2cd638e0a026300977c6 to your computer and use it in GitHub Desktop.
Save duxan/2cd638e0a026300977c6 to your computer and use it in GitHub Desktop.
# 1. set WD
setwd("C:/Users/Core-i5/Desktop/dataSci/3 Getting data/W3") # NOTE: change this PATH
# 2. make folder
if(!file.exists("./data")){
dir.create("./data")
}
# 3. make handle
fileURL <- "https://github.com/DataScienceSpecialization/courses/blob/master/03_GettingData/dplyr/chicago.rds?raw=true"
# 4. download data
download.file(fileURL, destfile = "./data/chicago.rds", method = "curl", extra='-L')
# 5. read data
chicago <- readRDS("./data/chicago.rds")
@azzaea
Copy link

azzaea commented Jun 21, 2015

On my machine, this code works changing the download.file as follows:
download.file(fileURL, destfile = "./data/chicago.rds", extra='-L',mode='wb')
Setting the method to 'curl' didn't help, so I thought to play with the mode parameter based on the advice that it is mostly good to set it to 'wb'..

@duxan
Copy link
Author

duxan commented Jun 21, 2015

Thanks for this alternative/addition!

It seems that RDS is binary file and in my case it was recognized as such by default. But it is not something to rely on, as suggested here: http://stackoverflow.com/questions/29814405/why-do-i-need-to-use-mode-wb-with-download-file-for-this-rds-file

@derderi
Copy link

derderi commented Jun 24, 2016

Thanks ,duxan
Yes,when using the
http://stackoverflow.com/questions/29814405/why-do-i-need-to-use-mode-wb-with-download-file-for-this-rds-file
it gives the right data ,and we can manipulate the Data with dplyr nicely and smoothly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment