Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

largenumber - large rowSums() results in Inf ? large number problem in R

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...