Expand description
AsNumeric / AsNumericVec: a number argument read the way Rβs
as.numeric() reads it, from numbers, text, or factor labels. The reading
rules are documented on AsNumericVec.
Re-exportsΒ§
use crate::from_r::BatchedErrors;πuse crate::from_r::SexpError;πuse crate::from_r::SexpLengthError;πuse crate::from_r::SexpTypeError;πuse crate::from_r::TryFromSexp;πuse crate::from_r::charsxp_to_cow_lossy;πuse crate::from_r::impl_option_try_from_sexp;πuse crate::from_r::map_strsxp_with;πuse crate::from_r::try_charsxp_to_str;πuse crate::into_r::IntoR;πuse crate::IsNA;πuse crate::IsNA;πuse crate::RLogical;πuse crate::SEXP;πuse crate::SEXPTYPE;πuse crate::SexpExt;π
StructsΒ§
- AsNumeric
- A numeric scalar read like Rβs
as.numeric(): from a double, integer, logical, character, or factor (by its labels) of length 1.NAof any type isNone. - AsNumeric
Vec - A numeric vector read like Rβs
as.numeric(): from a double, integer, logical, character, or factor (by its labels) vector.NAof any type isNone. - NotNumeric π
- A value that
as.numeric()would turn intoNAwith a coercion warning.
FunctionsΒ§
- check_
type π - Refuse every SEXPTYPE the markers do not read.
REALSXPis named as the expected type because that is the storage the value ends up in. - finish π
- Return the values, or the one batched error naming every rejected element.
- is_
blank π - Rβs
isBlankString: empty, or only blank characters. - is_
blank_ πchar - Whether
ccounts as blank for RβsisBlankString, which usesiswspacein a UTF-8 locale: Unicode whitespace except NEL (U+0085) and the no-break spaces U+00A0, U+2007 and U+202F, which neither glibc nor macOS classes as space. - is_
na_ πtoken - The missing-value token
"NA", with blanks around it at most. - level_
label π - The text of level
k(0-based) of a factorβslevelsSTRSXP. - parse_
charsxp π - Parse one CHARSXP the way
as.numeric()does. - parse_
nul_ π βterminated - Parse
sas RβsRealFromStringdoes, plus the"NA"token. - read_
factor_ πlabels - Read a factor by its labels: each level is parsed once, then every code
looks its level up. Code
NAisNone; a code outside the levels is a malformed factor (Rβsas.character()refuses it too). - read_
numeric π - Read any accepted input into
Vec<Option<f64>>, collecting every non-numeric element into one error. - refused_
by_ πno_ na - Whether
#[miniextendr(no_na)]refuses a value the markers read:None(every kind ofNA, the text"NA", a blank string) andNaN(also read from the text"NaN"), as RβsanyNA()refuses a numericNaN. - rest_
is_ πblank - Whether the bytes
R_strtodleft unread are blank. They follow an ASCII prefix of a valid UTF-8 string, so a failed UTF-8 check only happens for a split multi-byte character, which is not blank either.
Type AliasesΒ§
- Rejected π
- The rejected-element accumulator: 0-based index and the offending text.