Search code examples
rgithubdownloadgzipcompressed-files

R: Download Compressed File from Github ".tsv.gz" on a Mac


I have been unable to download a compressed ".tsv.gz" file from GitHub using R at the following URL on a Mac.

https://github.com/hadley/mastering-shiny/blob/main/neiss/injuries.tsv.gz

This should be a routine command, but download.file() and nothing at the following URL worked.

Downloading and unzipping GitHub zipped files directly in R


Solution

  • Simply changing the URL to:

    https://raw.githubusercontent.com/hadley/mastering-shiny/main/neiss/injuries.tsv.gz

    was sufficient. Weirdly, adding "?raw=TRUE" to the URL, https://github.com/hadley/mastering-shiny/blob/main/neiss/injuries.tsv.gz, which also leads to the "raw" version of the file, does not work so more color on this would be appreciated.