Skip to contents

Replaces the single col_type enum with independent properties, so the numeric character of a column (how it is stored, its measurement level) is kept separate from what it measures (its concept) and how it functions (its role). See the facet vocabulary in the "Column facets" section of this file.

Usage

data_col_facets(col_name, values, in_scale_block = NA)

Arguments

col_name

the column's name

values

the column's values

in_scale_block

whether this column belongs to a detected scale block (a run of consecutive same-prefix columns sharing a response range – see .detect_scale_blocks()), which is what makes it a likert item. Requires the whole data frame to determine, so the caller supplies it; NA (the default) means unknown and leaves the concept alone. A column's own values cannot decide this – whole numbers over a narrow range describe a trial counter as readily as a rating item.

Value

a list with representation, measurement_level, concept, role, unit, quality, parse_note, plus the numeric helpers carried over from data_col_type() (numeric_values, n_coerced, is_numeric, ambiguous) so data_check can compute statistics and target the LLM.

Details

Derives representation, measurement level, role, quality and a parse note from the rule primitive data_col_type() (preserving its edge cases), and the concept from data_col_concept(). The id/date concepts are inferred here from the role / representation, and likert from in_scale_block (see that argument). unit is left NA for concepts whose unit is not implied (an LLM/codebook can fill it); reaction_time seeds seconds/milliseconds from the value magnitude.

Author

Daniel Lakens and Levi Baruch

Examples

data_col_facets("RT", c(543, 612, 498, 701))
#> $representation
#> [1] "numeric"
#> 
#> $measurement_level
#> [1] "ratio"
#> 
#> $concept
#> [1] "reaction_time"
#> 
#> $role
#> [1] "measure"
#> 
#> $unit
#> [1] "milliseconds"
#> 
#> $quality
#> [1] "ok"
#> 
#> $parse_note
#> [1] NA
#> 
#> $numeric_values
#> [1] 543 612 498 701
#> 
#> $n_coerced
#> [1] NA
#> 
#> $is_numeric
#> [1] TRUE
#> 
#> $ambiguous
#> [1] TRUE
#> 
data_col_facets("subject_id", c("s01", "s02", "s03"))
#> $representation
#> [1] "text"
#> 
#> $measurement_level
#> [1] "nominal"
#> 
#> $concept
#> [1] "id"
#> 
#> $role
#> [1] "identifier"
#> 
#> $unit
#> [1] NA
#> 
#> $quality
#> [1] "ok"
#> 
#> $parse_note
#> [1] NA
#> 
#> $numeric_values
#> NULL
#> 
#> $n_coerced
#> [1] NA
#> 
#> $is_numeric
#> [1] FALSE
#> 
#> $ambiguous
#> [1] FALSE
#>