% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read_rds.R
\name{read_rds}
\alias{read_rds}
\title{Read a survey from an `.rds` file}
\usage{
read_rds(file, dataset_bibentry = NULL, id = NULL, doi = NULL)
}
\arguments{
\item{file}{Path to an `.rds` file containing a survey object.}

\item{dataset_bibentry}{Optional bibliographic metadata created with
[dataset::dublincore()] or [dataset::datacite()].}

\item{id}{Optional survey identifier. Defaults to the file name
without extension.}

\item{doi}{Optional DOI identifier for the survey.}
}
\value{
A `survey` object inheriting from `data.frame` and `tbl_df`
  with survey metadata attributes.
}
\description{
Import a serialized survey object stored in `.rds` format and return
it as a `survey` object with harmonized metadata attributes.
}
\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.
}
\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")

}
\seealso{
Other import functions:
\code{\link[=harmonize_survey_variables]{harmonize_survey_variables()}},
\code{\link[=pull_survey]{pull_survey()}},
\code{\link[=read_csv]{read_csv()}},
\code{\link[=read_dta]{read_dta()}},
\code{\link[=read_spss]{read_spss()}},
\code{\link[=read_surveys]{read_surveys()}}
}
\concept{import functions}
