I have a great data.matrix and I want to calculate the sum of the rows. Using rowSums
function results in Inf
values for sum because (presumably) the numbers are too large.
So I tried using Brobdingnagian numbers (from Brobdingnagian package, function as.brob) to deal with great numbers. But that is not working. Here is an example of what I have done with mtcars
example dataset
library(dplyr)
library(brobdingnag)
mtcars <- data.matrix(mtcars)
mtcars.rowsum <- mtcars %>% as.brob(.) %>% rowSums(.)
Error in h(simpleError(msg, call)) :
Error argument 'x' during method selection for function 'rowSums':
invalid class “brob” object: invalid object for slot "positive" in class "brob":
got class "matrix", should be or extend class "logical"
Selecting TRUE
or FALSE
in brob(.,positive = )
results in an error unused argument.
How to handle great numbers for rowSums()
in R? How to use as.brob
in a data.matrix?
question from:
https://stackoverflow.com/questions/65905047/large-rowsums-results-in-inf-large-number-problem-in-r 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…