maxalmond
maxalmond

Reputation: 415

Very small numbers in R

This is the first time I post something on a forum, so please be gentle. I've been programming in R for over a year now.

I'm trying to do a (mathematically very simple) statistical analysis of large datasets that come directly from a mass spectrometer. As you may know, these instruments are extremely precise and can measure very large, as well as very small voltages precisely: 50V to 0.00000000000000010V. The values are then reported to a tab-delimited file, which I can read into R.

However, at this point, I have the following problem: If I convert the data into doubles, I lose significant information. If I keep them in characters or factors, I cannot "use" them and calculate what I need to get.

Is there a work-around, so I can keep the precision AND use R? Would it be better to use a C++-based language, such as Matlab? Would Matlab be able to do this?

Upvotes: 3

Views: 2139

Answers (1)

Pork Chop
Pork Chop

Reputation: 29387

You can use Library gmp

http://cran.r-project.org/web/packages/gmp/

Example (Large Numbers)

install.packages("gmp")
library(gmp)
largevalue <- as.bigz(2305843009213694080000000)
largevalue 

Example (Small Numbers)

smallvalues <- asNumeric(cbind(0.0000000000000000000001,0.0000000000000000000003))
smallvalues

Upvotes: 4

Related Questions