Created
July 26, 2014 15:21
-
-
Save stevebargelt/f25dd4ca1956e3cc8630 to your computer and use it in GitHub Desktop.
Default Data Download Snippet in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Change the working directory | |
setwd("~/Google Drive/code/ThisProject") | |
# Change these three variables | |
datapath <- "./data" | |
filename <- "housing.csv" | |
fileUrl <- "http://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv" | |
###### | |
if (!file.exists(datapath)) { | |
dir.create(datapath) | |
} | |
pathandfilename <- paste(datapath, "/", filename, sep="") | |
if (!file.exists(pathandfilename)) { | |
download.file(fileUrl, destfile=pathandfilename, method="curl") | |
} | |
data <- read.csv(pathandfilename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment