recode_others: Function to recode others responses

Description Usage Arguments Value Examples

View source: R/03-recode_others.R

Description

Function to recode others responses

Usage

1
recode_others(df, var, ls, label = paste(var, 1:length(ls), sep = "."))

Arguments

df

A data.frame containing data from the Liberia Coverage Survey

var

A character value for variable name containing 'others' responses

ls

A list of thematically named string pattern vectors to use for searching and organising 'others' responses

label

A character vector for names of the resulting data.frame.

Value

A data.frame with same number of rows as 'df' and number of columns equal to the length of 'ls' containing recoded values

Examples

1
2
3
4
5
6
7
8
9
ifa3d <- c("delivery", "hospital", "constantly") # Did not go to hospital
ifa3e <- c("know") # Don't know about the tablets
ifa3f <- c("any", "go") # Didn't get any tablets
ifa3g <- c("given") # Was given but never took it
ifa3h <- c("interest", "interested", "Not") # Not interested
ifa3i <- c("Reasons") # No reasons
ls1 <- list(ifa3d, ifa3e, ifa3f, ifa3g, ifa3h, ifa3i)
names(ls1) <- paste("ifa3", letters[4:9], sep = "")
recode_others(df = coverageData1.r2, var = "ifa3a_other", ls = ls1)

validmeasures/liberiaData documentation built on Dec. 2, 2020, 3:32 a.m.