Depending upon how I download, I get two different files I am downloading the data set for the Kaggle competition on the titanic.
If I use the following code :
if (!file.exists(&quot;data&quot;)){
  dir.create(&quot;data&quot;)
}
fileUrl &lt;- 'https://www.kaggle.com/c/titanic/download/train.csv'

download.file(fileUrl, destfile='./data/train.csv') 

I get a 14kb file, however,
Paste this Url directly in your browser and you will download the correct file about 60kb.
This code works for sites where you don't need to be logged on. The Kaggle link only gives you the file when you are logged on to Kaggle. The file that is created with the code only contains html / javascript code of the Kaggle page.