dcast_StQ: Convert an StQ object into a dcasted data.table

Description Usage Arguments Value See Also Examples

Description

dcast_StQ returns a data.table in dcasted form (observations by row and variables by columns) with data from the input StQ object.

This method converts the slot Data from the input StQ object into a data.table with statistical units by row and variables specified in the input parameter VarNames by columns.

To distinguish between variables and qualifiers this function makes use of the slot DD of input StQ variable.

This method is indeed a wrapper for the function dcast.data.table of the package data.table, adapted to the structure of object StQ.

Usage

1
2
3
4
dcast_StQ(object, VarNames = NULL, UnitNames = FALSE)

## S4 method for signature 'StQ'
dcast_StQ(object, VarNames = NULL, UnitNames = FALSE)

Arguments

object

Object of class StQ whose slot Data will be converted.

VarNames

Character vector with names of the output variables (default NULL).

UnitNames

TRUE or FALSE (default) to return output with UnitNames in dcasted form.

Value

Returns a data.table with data from slot Data of the input StQ object with statistical units by rows and variables by columns. Only variables in VarNames will be output. If no variable name is specified, all variables in the input object will be output.

See Also

melt_StQ, dcast.data.table, melt.data.table, melt, dcast

Examples

1
2
3
4
5
6
7
8
data(ExampleStQ)
Mat <- dcast_StQ(ExampleStQ, VarNames = 'Turnover')
Mat
str(Mat)

dcast_StQ(ExampleStQ, VarNames = 'Employees')

dcast_StQ(ExampleStQ[ID != ''])

david-salgado/StQ documentation built on Aug. 12, 2021, 3:23 p.m.