measurement-autolevel: Automatically Adapt Measurement Levels

measurement_autolevelR Documentation

Automatically Adapt Measurement Levels

Description

The generic function measurement_autolevel changes the measurement levels of "item" objects to "nominal" or "ordinal", if the proportion of its values that have labels is above a certain threshold.

Usage

measurement_autolevel(x, ...)
## S4 method for signature 'ANY'
measurement_autolevel(x, ...) # Returns its argument as is
## S4 method for signature 'item.vector'
measurement_autolevel(x, 
                to=getOption("measurement.adapt.default","nominal"),
                threshold=getOption("measurement.adapt.threshold",.75),
                ...)
## S4 method for signature 'data.set'
measurement_autolevel(x, 
                to=getOption("measurement.adapt.default","nominal"),
                threshold=getOption("measurement.adapt.threshold",.75),
                except=NULL,
                only=NULL,
                ...)

Arguments

x

an object from class "item.vector" or "data.set".

to

a character vector, the target measurement level

threshold

the proportion of values, if reached the target measurement level is set

except

a vector with variable names, either as symbols (without quotation marks) or character strings (with quotation markes), the variables in the data set that are not to be changed by measurement_autolevel().

only

a vector with variable names, either as symbols (without quotation marks) or character strings (with quotation markes), the variables in the data set that are to be changed by measurement_autolevel().

...

other arguments, currently ignored.

Examples


 exvect <- as.item(rep(1:2,5))
 labels(exvect) <- c(a=1,b=2)
 codebook(exvect)
 codebook(measurement_autolevel(exvect))

 avect <- as.item(sample(1:3,16,replace=TRUE))
 labels(avect) <- c(a=1,b=2,c=3)
 bvect <- as.item(sample(1:4,16,replace=TRUE))
 labels(bvect) <- c(A=1,B=2,C=3,D=4)
 ds <- data.set(a=avect,b=bvect)
 codebook(ds)
 codebook(measurement_autolevel(ds))
 codebook(measurement_autolevel(ds,except=c(a,b)))
 codebook(measurement_autolevel(ds,only=a))

memisc documentation built on Oct. 24, 2024, 5:07 p.m.