Learn R Programming

dataquieR (version 2.1.0)

util_conversion_stable: Can a vector be converted to a defined DATA_TYPE

Description

the function also checks, if the conversion is perfect, or if something is lost (e.g., decimal places), or something is strange (like arbitrary suffixes in a date, just note, that as.POSIXct("2020-01-01 12:00:00 CET asdf") does not fail in R), but util_conversion_stable("2020-01-01 12:00:00 CET asdf", DATA_TYPES$DATETIME) will.

Usage

util_conversion_stable(vector, data_type, return_percentages = FALSE)

Value

numeric ratio of convertible entries in vector

Arguments

vector

vector input vector,

data_type

enum The type, to what the conversion should be tried.

return_percentages

logical return the percentage of stable conversions or matches.

Details

HINT: util_conversion_stable(.Machine$integer.max + 1, DATA_TYPES$INTEGER) seems to work correctly, although is.integer(.Machine$integer.max + 1) returns FALSE.