expand.two.level.factor: Expand two-level factor

View source: R/functions.R

expand.two.level.factorR Documentation

Expand two-level factor

Description

Create data.frame containing columns corresponding to first part of two-level factor and values equal to the second part of the latter.

Usage

expand.two.level.factor(
  vec,
  split = "",
  var.name = "var",
  comb.sep = ":",
  fill = NA
)

Arguments

vec

vector of two-level factor or character variable. Each element is represented as at least two-letter string.

split

character, which will be used to split vec on two parts.

var.name

name of variable, which will be used for generation names of newly created variables.

comb.sep

character, which will be used as a separator in newly created variable names between var.name and first part of two-level factor vec.

fill

default value to represent missing (NA) values in input vector.

Value

data.frame.

Examples

vec <- c("A1","B4",NA,"A4","C2")
expand.two.level.factor(vec)

DrrDom/pfpp documentation built on April 17, 2024, 10:24 a.m.