
Check a GADSdat for labeled fractional values.
Source: R/checkLabeledFractionals.R
checkLabeledFractionals.RdCheck a GADSdat object for any occurrences of fractional values in its metadata,
including both "truly" labeled values and values tagged as missings.
Value
Returns a data.frame, listing the affected varNames,
the labeled fractional values, their respective missings tags,
and whether they actually occur in the data (empty).
Details
This function is mainly useful to ensure a data set can be saved as a .dta file.
Unlike, for example, SPSS, Stata only allows for integer values
(and so-called extended missing values) to be labeled
(Stata manual: 12.6.3).
Trying to export (meta) data with labeled fractional values would therefore cause problems
and run into an error from haven's write_dta function.
See also
Other dataset compliance checks:
checkIntOverflow(),
getProgramLimit()
Examples
# Introduce a fractional value into meta data
pisa2 <- recodeGADS(GADSdat = pisa,
varName = "schtype",
oldValues = 2,
newValues = .5)
checkLabeledFractionals(pisa2)
#> varName value missings empty
#> 1 schtype 0.5 valid FALSE