pullOneValue: Pull one set of values from variables included in data which...

Description Usage Arguments Value Examples

View source: R/pullOneValue.R

Description

When some part of the data is missing, the missing information may be recovered from another source of information. This function scans all variables which are thought to include essentially the same information, and pulls value from a variable which is not missing.

Usage

1
2
pullOneValue(data = NULL, varlist = c(""), check = TRUE,
  choose = c("first", "last", "lower", "upper"))

Arguments

data

a data.frame in which variables are included

varlist

a character vector of variable list which is assumed to contain the same information.

check

a logical value specifying whether to scan all variables in varlist for incompatible values or not.

choose

a character value specifying which to choose among incompatible values. To choose ‘first’ or ‘last’ depends on the order of the data. ‘lower’ and ‘upper’ cannot be used for character variables. This option works only when check option is enabled (set to TRUE).

Value

a vector including one set of values obtained from varlist.

Examples

1
2
3
dat <- data.frame(a1=c(NA,2,3), a2=c(1,NA,2), a3=c(1,2,NA), b=c(10,11,20))
dat
pullOneValue(dat, c("a1", "a2", "a3"))

epifit documentation built on May 29, 2017, 3:43 p.m.