DataDummyHierarchy: Create a (signed) dummy matrix for hierarcical mapping of...

View source: R/DataDummyHierarchies.R

DataDummyHierarchyR Documentation

Create a (signed) dummy matrix for hierarcical mapping of codes in data

Description

Create a (signed) dummy matrix for hierarcical mapping of codes in data

Usage

DataDummyHierarchy(dataVector, dummyHierarchy)

DataDummyHierarchies(data, dummyHierarchies, colNamesFromData = FALSE)

Arguments

dataVector

A vector of codes in data

dummyHierarchy

Output from DummyHierarchy

data

data

dummyHierarchies

Output from DummyHierarchies

colNamesFromData

Column names from data when TRUE

Details

DataDummyHierarchies is a user-friendly wrapper for the original function DataDummyHierarchy. When colNamesFromData is FALSE (default), this function returns ⁠mapply(DataDummyHierarchy,⁠ ⁠data[names(dummyHierarchies)],⁠ ⁠dummyHierarchies)⁠.

Value

A sparse matrix. Column names are taken from dataVector (if non-NULL) and row names are taken from the row names of dummyHierarchy.

Author(s)

Øyvind Langsrud

Examples

z <- SSBtoolsData("sprt_emp_withEU")[1:9, ]
hi <- FindHierarchies(z[, c("geo", "eu", "age", "year")])
dhi <- DummyHierarchies(hi, inputInOutput = TRUE)
DataDummyHierarchies(z, dhi, colNamesFromData = TRUE)

SSBtools documentation built on Oct. 30, 2024, 5:09 p.m.