utlede_ferdigstilt: Add binary variable for table-status

View source: R/utlede_variabler.R

utlede_ferdigstiltR Documentation

Add binary variable for table-status

Description

The function utlede_ferdigstilt() uses the values of variable var to create a new column named ferdigstilt_suffix in df before df is returned from the function. The new variable is given the value ja if var is 1, and value nei if var is -1 or 0.

Usage

utlede_ferdigstilt(df, var = .data$SkjemaStatusStart, suffix = "startSkjema")

Arguments

df

data.frame, must contain a numerical status-variable with values -1, 0 or 1.

var

variable name of the numerical status-variable. Default value is SkjemaStatusStart.

suffix

wanted suffix in the new variable's name: ferdigstilt_suffix. Default values is "startSkjema".

Value

The data.frame given in input df is returned as it is, with one new column added.

Examples

x <- data.frame(SkjemaStatusStart = c(-1,-1,0,0,1,-1,0,1,NA),
                SkjemastatusHovedskjema = rep(0,9),
                SkjemaStatusUtskrivelse = rep(-1,9),
                SkjemaStatusKomplikasjoner = c(rep(-1,4), rep(1,3), NA, NA))

utlede_ferdigstilt(x, var = SkjemaStatusStart, suffix = "startSkjema")

utlede_ferdigstilt(x,
                   var = SkjemaStatusStart,
                   suffix = "startSkjema") %>%
   utlede_ferdigstilt(.,
                      var = SkjemastatusHovedskjema,
                      suffix = "hovedSkjema") %>%
   utlede_ferdigstilt(.,
                      var = SkjemaStatusKomplikasjoner,
                      suffix = "komplikSkjema")

Rapporteket/NORIC documentation built on Feb. 15, 2024, 5:25 p.m.