% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pull_survey.R
\name{pull_survey}
\alias{pull_survey}
\title{Retrieve a survey from a survey list}
\usage{
pull_survey(survey_list, id = NULL, filename = NULL)
}
\arguments{
\item{survey_list}{A list of `survey` objects.}

\item{id}{Optional survey identifier.}

\item{filename}{Optional source file name.}
}
\value{
A single `survey` object.
}
\description{
`pull_survey()` retrieves a survey object from a list created with
[read_surveys()].

Surveys can be selected using:

- the survey identifier stored in the `"id"` attribute, or
- the original source file name stored in the `"filename"` attribute.
}
\details{
Extract a single `survey` object from a list of surveys using either
its survey identifier or source file name.


Either `id` or `filename` must be supplied.

The function throws an error if:

- neither argument is provided;
- the requested survey cannot be found;
- or multiple surveys match the query.
}
\examples{
examples_dir <- system.file(
  "examples",
  package = "retroharmonize"
)

survey_files <- dir(
  examples_dir,
  pattern = "\\\\.rds$"
)

example_surveys <- read_surveys(
  file.path(examples_dir, survey_files)
)

pull_survey(
  example_surveys,
  id = "ZA5913"
)

}
\seealso{
[read_surveys()]

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