numbersFromCategoricalVariableSets: Get numbers from attributtes of Pick One and Pick One - Multi...

View source: R/scalevariableset.R

numbersFromCategoricalVariableSetsR Documentation

Get numbers from attributtes of Pick One and Pick One - Multi questions

Description

Extracts the codeframe and value attributes from the (R data.frame/factor representation of) Displayr's Categorical Variable Sets (PickOne and PickOneMulti questions in Q) and applies them to the input factors/data.frame to convert it to its underlying values.

Usage

numbersFromCategoricalVariableSets(x)

Arguments

x

A variable set from Q/Displayr (an R factor or data.frame with special attributes).

Details

levels(x) are always present in the names of the codeframe attribute, unless codes are hidden. The codeframe contains sourcevalues for each code/level, which need to be mapped from the sourcevalues attribute (original values as read in with the data set) to the (possibly user-modified) values attribute.

A level that is the result of a merge will contain multiple source values for that element in the codeframe. These are mapped to the corresponding underlying values in the values attribute and averaged.

Value

For data.frame (vector) x, A matrix (vector) of numeric values with number of rows (elements) equal to NROW(x).


Displayr/flipTransformations documentation built on Feb. 26, 2024, 12:47 a.m.