[R] Weird options(digits=n) behaviour
Fernando Henrique Ferraz Pereira da Rosa
mentus at gmx.de
Thu Jan 30 00:29:03 CET 2003
I noticed some very weird behaviour of the function: options(digits=n),
where n is the number of digits you would expect to get in R calculations.
Let's take a example:
> options(digits=4)
> getdata(caso.pool.k3.r3.e2)
[1] 6.053 2.641 -3.639 14.259 6.082
Which works fine... now, trying again, with different data:
> options(digits=4)
> getdata(controle.pool.k3.r3.e2)
[1] -0.03091 1.60310 -4.90588 5.07379 -0.04418
>
Which gives me 6 digits instead of 6. If I try digits=2, it then works
with this data:
> options(digits=2)
> getdata(controle.pool.k3.r3.e2)
[1] -0.031 1.603 -4.906 5.074 -0.044
But not with the first one:
> getdata(caso.pool.k3.r3.e2)
[1] 6.1 2.6 -3.6 14.3 6.1
getdata source code is as folllows:
function(v) {
o <- c(mean(v),sd(v),min(v),max(v),median(v))
o
}
What is going on?
--
More information about the R-help
mailing list