Interface to National Sleep Research Resource

Allows users to access data from the National Sleep Research Resource ('NSRR') <>.

Travis buildstatus AppVeyor BuildStatus Coveragestatus

The goal of nsrr is to allow users to access data from the National Sleep Research Resource (’NSRR’) (


You can install the released version of nsrr from CRAN with:



To retrieve your NSRR token, go to, 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:


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:



NSRR data sets

Here is how you can access the NSRR datasets list:

df = nsrr_datasets()

NSRR data set files

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

df = nsrr_dataset_files("shhs", path = "datasets")
  dataset                         full_path    folder
1    shhs                  datasets/archive datasets/
2    shhs    datasets/eeg-spectral-analysis datasets/
3    shhs             datasets/hrv-analysis datasets/
4    shhs             datasets/ datasets/
5    shhs           datasets/ datasets/
6    shhs datasets/shhs1-dataset-0.13.0.csv datasets/
                 file_name is_file file_size
1                  archive   FALSE         0
2    eeg-spectral-analysis   FALSE         0
3             hrv-analysis   FALSE         0
4       TRUE     10175
5     TRUE     11284
6 shhs1-dataset-0.13.0.csv    TRUE  24305606
                 file_checksum_md5 archived
1                             <NA>    FALSE
2                             <NA>    FALSE
3                             <NA>    FALSE
4 1432504de974e712e1cd7d99038bdfd5    FALSE
5 c53ea822afa2e78ba601da508562775d    FALSE
6 212cf854c1e04ce6d75cb6580917e3a9    FALSE

Downloading NSRR data set files

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

url = nsrr_download_url("shhs", path = "datasets/")
# print URL
dl = nsrr_download_file("shhs", path = "datasets/")
[1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpMeg78M/"
cat(head(readLines(dl$outfile)), sep = "\n")
## 0.13.1 (December 20, 2017)
- Fix odd symbols in variable descriptions
## 0.13.0 (December 7, 2017)

Listing All NSRR data set files

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


but it may take some time.


nsrr 0.1.0

  • First submission to CRAN.

  • Added a file to track changes to the package.

  • Added download functionality to the package.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.2.0 by John Muschelli, 2 years ago

Report a bug at

Browse source code at

Authors: John Muschelli [aut, cre]

Documentation:   PDF Manual  

GPL-3 license

Imports httr, jsonlite, tools, digest, stats, utils

Suggests covr, DT, knitr, rmarkdown, testthat, xml2, rvest, readr

See at CRAN