0

I'm trying to download the titanic training data set from Kaggle and am running into issues with download.file(). I've tried all possible values for the method argument, as well as changing the https to http, and the file doesn't seem to download correctly: it seems to be downloading a HTML file and I'm not sure how to fix this.

(the dataset)

https://www.kaggle.com/c/titanic/data

My code...

download.file("https://www.kaggle.com/c/titanic/download/train.csv",
          "/Users/marsh/Downloads/data/titanic_train.csv", method = "curl")
test <- read.csv("/Users/marsh/Downloads/data/titanic_train.csv")
test

X.html..head..title.Object.moved..title...head..body.
1 <h2>Object moved to <a href=/account/login?
ReturnUrl=%2fc%2ftitanic%2fdownload%2ftrain.csv>here</a>.</h2>
2                                                                                            
</body></html>
m_squared
  • 105
  • 9
  • [https://stackoverflow.com/questions/23028760/download-a-file-from-https-using-download-file] looks similiar to your question. Try to work from there and post your solution here, so other people can solve the same problem. – Nucore Sep 18 '17 at 02:57
  • That was the first thread I looked at when I first ran into the problem. I think my problem differs in that R is accessing the URL, but is just returning it in the wrong format (HTML). I don't have any experience with HTML so I'm not totally sure if the problem is within R or the link itself. – m_squared Sep 18 '17 at 14:18
  • I think the main problem is in download.file(). If I just run that part of the code and check the ./Downloads/data/ directory, the file is saved AS a .csv, but is in HTML format. – m_squared Sep 18 '17 at 14:28

0 Answers0