2

I have a variable, which contains mpfr object.

> currentPrice <- mpfr(as.character(reduceData[1, 2]))
> currentPrice
1 'mpfr' number of precision  97   bits 
[1] 14.22857142857142857142857143301

How can I write this value to text file without cutting it and tranforming to short version like this:

> as.numeric(currentPrice)
[1] 14.22857

Thank you for your attention.

Command dput outputs this:

> dput(currentPrice)
new("mpfr"
    , .Data = list(<S4 object of class structure("mpfr1", package = "Rmpfr")>)
)

1 Answers1

1

using print method called print.mpfr in Rmpfr package

library( 'Rmpfr' )
currentPrice <- mpfr( '14.22857142857142857142857143301', precBits = 260 )

sink( 'filename.txt' )
print(currentPrice, digits = 260)
sink();

Output in your file.

# 1 'mpfr' number of precision  260   bits 
# [1] 14.2285714285714285714285714330100000000000000000000000000000000000000000000000037941082567172255283680561956483693602320305788044194384954889318036909905910031240694550294963195196244918820116425935087779567863032980333526378302622106275521218776702880859375
Sathish
  • 12,453
  • 3
  • 41
  • 59