read_rds: Read a survey from an '.rds' file

View source: R/read_rds.R

read_rdsR Documentation

Read a survey from an '.rds' file

Description

Import a serialized survey object stored in '.rds' format and return it as a 'survey' object with harmonized metadata attributes.

Usage

read_rds(file, dataset_bibentry = NULL, id = NULL, doi = NULL)

Arguments

file

Path to an '.rds' file containing a survey object.

dataset_bibentry

Optional bibliographic metadata created with [dataset::dublincore()] or [dataset::datacite()].

id

Optional survey identifier. Defaults to the file name without extension.

doi

Optional DOI identifier for the survey.

Details

This function restores survey objects previously saved with [base::saveRDS()] or exported from the 'retroharmonize' workflow. The returned object retains survey metadata and gains additional provenance attributes such as source file name and file size.

If the file cannot be read, an empty 'survey' object is returned and a warning is emitted.

The function:

- restores the serialized object, - validates source file information, - normalizes 'rowid', - records provenance metadata, - and stores object and source file sizes as attributes.

Value

A 'survey' object inheriting from 'data.frame' and 'tbl_df' with survey metadata attributes.

See Also

Other import functions: harmonize_survey_variables(), pull_survey(), read_csv(), read_dta(), read_spss(), read_surveys()

Examples

path <- system.file(
  "examples",
  "ZA7576.rds",
  package = "retroharmonize"
)

survey_object <- read_rds(path)

attr(survey_object, "id")
attr(survey_object, "filename")
attr(survey_object, "doi")


retroharmonize documentation built on May 21, 2026, 9:06 a.m.