Example:
library(Rmpfr)
x.mpfr <- 1:11 + Rmpfr::mpfr(1.e20, precBits = 1000)
var(x.mpfr)
Error in var(x.mpfr) : is.atomic(x) is not TRUE
Question:
How to make the function var() run with the mpfr vector x.mpfr?
To be precise, here the var() is a demonstration example. In general, my question is, how to use a function with mpfr data when the type of mpfr triggered the atomic error? Is there any convenient solution of doing it without rewriting a function with mpfr embeded?
If you want to use numbers of class
"mpfr"and base R functions give that error, the only way I know of is to write your own functions.In the example below I have made
VARandSDgeneric, so that calls of the typefun(x)work.See also my answer to this R-Help thread, mirrored here.
Created on 2023-04-18 with reprex v2.0.2