Downloading data from NSRR

Token

To retrieve your NSRR token, go to https://sleepdata.org/dashboard, and sign in. This token will allow you access to any data sets you have requested access to. If you do not have access, then it will allow you to download files that are publicly available.

Set the token by adding this to your ~/.Renviron file:

NSRR_TOKEN="YOUR TOKEN GOES HERE"

The token is accessible via token = Sys.getenv("NSRR_TOKEN"). Each nsrr function also has the argument token to pass through if you do not wish to set it.

To determine if you are authenticated, you can use:

library(nsrr)
nsrr_auth()
#> $authenticated
#> [1] TRUE
#> 
#> $username
#> [1] "muschellij2"
#> 
#> $full_name
#> [1] ""
#> 
#> $first_name
#> NULL
#> 
#> $last_name
#> NULL
#> 
#> $email
#> [1] "muschellij2@gmail.com"

Examples

NSRR data sets

Here is how you can access the NSRR datasets list:

NSRR data set files

Here we first get a list of the files in the datasets sub-directory from the shhs data set:

Downloading NSRR data set files

We can then download the CHANGELOG.md file as it’s publicly accessible.

Listing All NSRR data set files

To list all the files, recursively, you would run:

but it may take some time.