virtblock: Splits data matrix according to feature of group variable;...

Description Usage Arguments Value Author(s) Examples

Description

Function virtblock expands splits and expands a data matrix according to features of a group variable in it. Data matrix is a persons x variables matrix including a group variable. Part of the variables (items) should be split into independent variables / columns. The splitting is due to a feature of the group variable on the items variables. For example the group variable indicates booklets. These booklets have different positions for the items. Result is a data matrix with more columns than the original data matrix because those item variable that differ in the feature (position) are split into two or more columns (dependent on the level of the feature)

Usage

1
virtblock(data, where_items, where_group, pos_key)

Arguments

data

contains data and a group variable

where_items

index vector which indicates which items have to be split

where_group

index of the grouping variable (scalar)

pos_key

integer matrix; feature x items; start with 1!

Value

list of expanded data matrix with the split columns; each list element contains the new columns representing the expandation of one column in the original data matrix; colname shows which feature the new columns have

Author(s)

Manuel Reif, Christine Hohensinn

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(DataprepMisc)

exdat_v <- matrix(sample(c(0,1),3*5, rep=TRUE),ncol=3)
colnames(exdat_v) <- paste0("it", 1:3)
group <- sample(1:3, 5, rep=TRUE)
position <- matrix(c(1,2,1,2,2,1),ncol=3)
exdat_v2 <- cbind(exdat_v, group)
exdat_v2

virtblock(exdat_v2, 1:3, 4, position)

christinehohensinn/DataprepMisc documentation built on May 13, 2019, 7 p.m.