Search

Friends

Atomspheric CO2 (PPM)

Archives

Blather

Uptime verified by Wormly.com

10 November 2007

Significant Digits in R CRAN

I get a bit sick of scientific notation in R. And when I try to turn it off, I get sick of all the decimal places. These options seem to mostly stop scientific notation and give a happy number of decimal places.

options(scipen = 6) # bias against scientific notation
options(digits = 1) # show fewer decimal places

22 June 2007

Calculating a Bond Yield

> f = function(y) (5/(1+y) + 5/((1+y)^2) + 105/((1+y)^3) - 88)^2
> optimize(f, c(0,1))
$minimum
[1] 0.09807912

$objective
[1] 8.321122e-06

Two lines. R is so sweet.

0.091 seconds