diff --git a/doc/NEWS.Rd b/doc/NEWS.Rd index 035ddb8630..b0a0cf26cc 100644 --- a/doc/NEWS.Rd +++ b/doc/NEWS.Rd @@ -346,6 +346,10 @@ If there were a platform which used an underlying type of a different size this would be an ABI-breaking change (but we are unaware of any such platform). + + \item There is a new function \code{asRboolean}, a variannt of + \code{asLogical} more suitable to converting logical arguments to + \code{Rboolean}. } } diff --git a/doc/manual/R-exts.texi b/doc/manual/R-exts.texi index 53d359ffaa..ad1342a5c4 100644 --- a/doc/manual/R-exts.texi +++ b/doc/manual/R-exts.texi @@ -13176,11 +13176,19 @@ failed. There are also @code{Rf_asInteger}, @code{Rf_asReal} and @code{Rf_asComplex}. The function @code{Rf_asChar} returns a @code{CHARSXP}. All of these functions ignore any elements of an input vector after the first. + +@code{Rf_aaRboolean} is a stricter version of @code{Rf_asLogical} +introduced in @R{}@tie{}4.5.0. It returns type @code{Rboolean} and +gives an error for an input of length other than one, and for +coercion failure. + +but gives an weeo @apifun Rf_asInteger @apifun Rf_asLogical @apifun Rf_asReal @apifun Rf_asComplex @apifun Rf_asChar +@apifun Rf_asRboolean The function @code{Rf_asCharacterFactor} converts a factor to a character vector. @apifun Rf_asCharacterFactor diff --git a/src/include/Rinternals.h b/src/include/Rinternals.h index 3fb375b916..9cf609d4ab 100644 --- a/src/include/Rinternals.h +++ b/src/include/Rinternals.h @@ -487,6 +487,7 @@ int Rf_asLogical(SEXP x); int Rf_asInteger(SEXP x); double Rf_asReal(SEXP x); Rcomplex Rf_asComplex(SEXP x); +Rboolean Rf_asRboolean(SEXP x); // also included in R_ext/Rallocators.h @@ -900,6 +901,7 @@ void R_orderVector1(int *indx, int n, SEXP x, Rboolean nalast, Rboolean de #define asInteger Rf_asInteger #define asLogical Rf_asLogical #define asLogical2 Rf_asLogical2 +#define asRboolean Rf_asRboolean #define asReal Rf_asReal #define asS4 Rf_asS4 #define charIsASCII Rf_charIsASCII