Considering the following vector:
> v1
[1] 0.000000e+00 0.000000e+00 1.110223e-16 4.440892e-15 3.266195e-08 2.531242e-07
1.041204e-05 1.172329e-05 1.672447e-05 1.803203e-05
I have applied mpfr from function (from the Rmpfr package)to v1:
> v2<-sapply(v1,function(x){mpfr(x,5)})
v2 is apparently a list, but I cannot get the actual value. I have tried using unlist, v2[[]], converting to character v2[[]] or vector..
> v2
[[1]]
'mpfr1' 0
[[2]]
'mpfr1' 0
[[3]]
'mpfr1' 1.11e-16
Solution of the problem
Actually I had a similar problem, since this is the first time I am using this package. Anyway, I have found a simple solution, albeit not the most elegant, I may add...:
# Compute 1/7 with 1000 bit precision and store the value in a character object
x <- mpfr(1,1000)/7
x.output <- capture.output(x)[2]
result <- substr(x.output,5,nchar(x.output))
Aucun commentaire:
Enregistrer un commentaire