gethklips {tidyklips} | R Documentation |
‘gethklips()’ is used to obtain data.frame for KLIPS (head of household survey)
Description
‘gethklips()’ is used to obtain data.frame for KLIPS (head of household survey)
Usage
gethklips(
path,
year,
datatype = c("stata", "spss", "sas", "xlsx"),
klipsvars = c("0141", "2102"),
outvars = c("province", "income")
)
Arguments
path |
A string vector specifying folder containing KLIPS head of household survey data |
year |
an integer vector specifying the years from 1998 to 2023 that the user wants to include in the dataframe. |
datatype |
A string vector specifying the format of the raw data you want to convert to a data frame ("spss", "sas", "stata", "excel") |
klipsvars |
A string vector specifying the variables in the raw data that you want to convert to a data frame ("0141", "2102") |
outvars |
A string vector specifying the variable names of converted data ("province", "income") |
Value
A data frame containing klips household member data with the specified years and variables.
-
gethklips()
returns an integer dataframe with two and more columns and rows for each head of household. The first column,hhid
, refers to the respondent id number, and the last column,year
, refers to the year that the user wants to include in the dataframe.
Examples
path <- system.file("extdata", package = "tidyklips")
df <- gethklips(path = path, year = 2023, datatype = "stata")
df %>%
dplyr::group_by(year) %>%
dplyr::summarise(count = dplyr::n()) %>%
dplyr::mutate(proportion = count / sum(count))