In theory this should be a straightforward task with the download.file function, but as I recently found, it’s a little trickier than that (but really not that much trickier).1 The main things you have to do are
Specify mode = "wb" in download.file
Use unz to unzip
Example code below. I used a real url in the example that downloads data on NIH grants from this page.
This is what you should get at the end:
I relied on this Stack Overflow post to figure this out, and it has a few variants on the solution that I’m using here. ↩
Leave a Comment