getData: Import Metapsy databases into the R environment

View source: R/getData.R

getDataR Documentation

Import Metapsy databases into the R environment


This function allows to download all publicly available versions of Metapsy databases into your R environment.


        version = NULL,
        include.metadata = TRUE)



character. The shorthand assigned to the database that should be downloaded. Shorthands are listed under "Metadata" in the database documentation entry. Alternatively, all available databases and their shortcodes can be accessed by running listData().


character. The version number to be downloaded. Default is NULL, which downloads the latest version.


logical. If set to TRUE, the function will return an R6::R6Class() object that includes metadata associated with the database version. See "Value".


If include.metadata is set to TRUE, the getData function will return both the requested dataset itself, as well as the metadata associated within in it. Metadata items included by default are:

  • database.doi: The digital object identifier of the database ("Concept DOI" in the Zenodo API. This DOI will always resolve to the latest database version).

  • documentation.url: URL of the database documentation entry on the Metapsy Documentation page.

  • github.repo.url: URL of the specific Github repository state at which the database was released.

  • Date of the last search.

  • last.updated: Date of the last database updated (release).

  • license: License of the database.

  • Link to download the entire database from Zenodo.

  • title: Title of the database (including its version).

  • variable.description: Description of the variables included in the dataset.

  • version: Version of the database.

  • version.doi: DOI associated with the specific version of the database. In contrast to the database.doi, this identifier will also link to this specific database version.

The returned R6::R6Class() object also contains a few helpful functions, which can be called directly from the object:

  • downloadZip(): This will download the database (including metadata) as a .zip file from its Zenodo repository.

  • openDocumentation(): This opens the database documentation entry on the Metapsy Documentation page.

  • openGitRepo(): This opens the Github repository of the database at the state of its release.

  • returnMetadata(): Returns the entire metadata stored in the metapsyDatabase R6 object as a list.

  • variableDescription(): This prints a variable description of the database in the R Console.

If include.metadata is FALSE, the function will return the dataset as a simple data.frame.


Mathias Harrer

See Also



## Not run: 
# List all available databases

# Get latest version of the 'depression-psyctr' database
d <- getData("depression-psyctr")

# Get version 22.2.0 of the 'depression-psyctr' database
d <- getData("depression-psyctr", "22.2.0")

# Show variable description

# Open online documentation

# Analyze using metapsyTools

## End(Not run)

metapsy-project/metapsyData documentation built on Jan. 18, 2024, 5:55 a.m.