library(Rmpfr)
mynumber <- new("mpfr", .Data = list(new("mpfr1", prec = 50L, exp = c(1045L,
0L), sign = 1L, d = c(151748608L, -358118319L)), new("mpfr1",
prec = 50L, exp = c(20L, 0L), sign = 1L, d = c(-1114947584L,
-1905679017L)), new("mpfr1", prec = 50L, exp = c(-55L, -1L
), sign = 1L, d = c(-1449918464L, -906197701L)), new("mpfr1",
prec = 50L, exp = c(221L, 0L), sign = 1L, d = c(819707904L,
-1329031570L))))
mynumber
is a class mpfr
object with 4 numbers in it. I want to cbind
mynumber
with a column of 0s, i.e.
> cbind(rep(0, 4), mynumber)
mynumber
[1,] 0 ?
[2,] 0 ?
[3,] 0 ?
[4,] 0 ?
This gives me ???? in the second column, so I tried to change mynumber
to class numeric
first
mydata <- cbind(rep(0, 4), sapply(mynumber, asNumeric))
> mydata
[,1] [,2]
[1,] 0 Inf
[2,] 0 5.833223e+05
[3,] 0 2.189941e-17
[4,] 0 2.327185e+66
However, since the first number in mynumber
is really big, using asNumeric changed it into Inf
instead.
Edit: My ultimate goal is to run:
mydata <- cbind(rep(0, 4), sapply(mynumber, asNumeric))
> mydata/rowSums(mydata)
[,1] [,2]
[1,] 0 NaN
[2,] 0 1
[3,] 0 1
[4,] 0 1
and not have it print out NaN.