Nikhilesh Jha
Nikhilesh Jha

Reputation: 11

Downloading/reading files in R

I am trying to write a reproducible code in order to read .csv file from a Kaggle competition. I can download the data manually and the feed it to R Studio. However, whenever I try to read the data through R Studio (Version 1.0.143) on Mac I get an html file.

Here are the codes I have tried using the function download.file and read.csv,

download.file("https://www.kaggle.com/c/5407/download/test.csv",destfile="test.csv) And

download.file("https://www.kaggle.com/c/5407/download/test.csv", destfile="test.csv", method="curl",mode="w") also,

test <- read.csv(url("https://www.kaggle.com/c/5407/download/test.csv"))

The output I am getting from the command head(test) is `

X..DOCTYPE.html.
1                                                <html>
2                                                <head>
3     <title>Kaggle: Your Home for Data Science</title>
4                                <meta charset=utf-8 />
5             <meta name=robots content=index, follow/>
6             <meta name=theme-color content=#008ABC />

` Clearly not a .csv file.

Upvotes: 1

Views: 725

Answers (1)

nadizan
nadizan

Reputation: 1373

There is no csv-file on that webpage. Just manually put in https://www.kaggle.com/c/5407/download/test.csv in your web-browser and you will see.

You might want to look at RSelenium to be able to log-in and download that file. Otherwise, manually download it to your computer then load it from the directory.

Upvotes: 1

Related Questions