Convert to PIP format and add class
as_pip.Rd
Convert welfare, weight and (optionally) imputed id vectors to PIP format from a data.frame
Arguments
- dt
data.frame with welfare data
- welfare_var
character: variable name of welfare vector in dt
- weight_var
character: variable name of weight vector in dt
- imputation_id_var
character: variable name of imputation ID vector in dt
- pip_type
character: One of "md", "id", "gd_*". Generally this comes from the output of
identify_pip_type()
- groupdata_threshold
numeric: threshold to discriminate between micro data an group data. Default is 200 observations
- verbose
logical: Whether to display important messages about your data or query
Examples
# Example 1: Basic usage with md data.
as_pip(dt = pip_md,
welfare_var = "welfare",
weight_var = "weight") |>
class()
#> ! vectors not sorted
#> → PIP type identified: "md"
#> [1] "pipmd" "data.table" "data.frame"
# Example 2: Including imputation_id_var
as_pip(dt = pip_id,
welfare_var = "welfare",
weight_var = "weight",
imputation_id_var = "imputation_id") |>
class()
#> ! vectors not sorted
#> → PIP type identified: "id"
#> [1] "pipid" "pipmd" "data.table" "data.frame"
# Example 3: Basic usage with gd data and explicit pip_type
as_pip(dt = pip_gd,
welfare_var = "L",
weight_var = "P",
pip_type = "gd_1") |>
class()
#> Warning: replacing previous import ‘collapse::fdroplevels’ by ‘data.table::fdroplevels’ when loading ‘wbpip’
#> ℹ columns "welfare" and "P" have been rescaled to range (0,1]
#> [1] "pipgd" "data.table" "data.frame"