View source: R/subset_surveys.R
| subset_surveys | R Documentation |
Retain selected variables from one or more surveys, either loaded in memory or read sequentially from files.
subset_surveys(
survey_list = NULL,
survey_paths = NULL,
rowid = "rowid",
subset_name = "subset",
subset_vars = NULL,
crosswalk_table = NULL,
import_path = NULL,
export_path = NULL
)
survey_list |
A survey object or a list of survey objects. If 'NULL', surveys are read from files. |
survey_paths |
A character vector of survey file paths. |
rowid |
Name of the observation identifier column. Defaults to '"rowid"'. |
subset_name |
Character string appended to subset filenames. |
subset_vars |
Character vector of variables to retain. If 'NULL', all variables are retained unless a crosswalk table is supplied. |
crosswalk_table |
An optional crosswalk table created with [crosswalk_table_create()]. |
import_path |
Optional directory containing survey files. |
export_path |
Optional directory for exporting subsetted surveys as RDS files. |
When a crosswalk table is supplied, surveys are matched by their identifiers and variables are selected using 'var_name_orig'. Original variable names, values and labels are preserved.
In-memory surveys retain their original ordering. Crosswalk rows do not determine survey ordering.
Variables unavailable in a survey are silently omitted.
A list of subsetted survey objects, or a character vector of exported filenames when 'export_path' is supplied.
[crosswalk_table_create()], [crosswalk()], [read_surveys()]
s <- read_rds(
system.file("examples", "ZA7576.rds",
package = "retroharmonize"
)
)
subset_surveys(
survey_list = s,
subset_vars = c("rowid", "isocntry", "qa14_1"),
subset_name = "example"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.