rfiledownload

Download a csv file from harvard dataverse


I want to download the following data set https://doi.org/10.7910/DVN/M3D2NR using R instead of making the user do it manually. One has to go to the web, select the file and then press "download". Is there a way to make it automatic using R?


Solution

  • The tricky part is to find out the url, where the file is hosted. Once you find that out, you can use download.file and providing appropriate destination address to save it

    enter image description here

    download.file("https://dataverse.harvard.edu/api/access/datafile/3086908?gbrecs=true", 
                   paste0(getwd(), "/filename.csv"))