[R] Problems with the sort function!?
Kay.Pilz at ruhr-uni-bochum.de
Fri Nov 5 14:48:22 CET 2004
I am running R 2.0.0 with a Win XP operating system. The same problem occured
with R 1.9.1 but not with R.1.3.1 on a Win NT computer.
My request is about the following problem with the sort function:
The vector price is a vector of 789 asset prices of the following form,
 1.1315 1.1314 1.1313 1.1314 1.1315 1.1316 1.1315 1.1317
 1.1316 1.1316
Then the returns are defined to be the differences,
> ret <- diff(price)
 -1e-04 -1e-04 1e-04 1e-04 1e-04 -1e-04 2e-04 -1e-04
 0e+00 0e+00
Here R recognizes the first two entries and also the second ones to be equal
(I did not found any two equal entries, where R didnt recognized this
But after sorting the vector, this ist not longer true,
> s <- sort(ret)
 -5e-04 -5e-04 -5e-04 -5e-04 -5e-04 -4e-04 -4e-04 -4e-04
 -4e-04 -4e-04
Taking the difference of the first two entries yields
which seems to be a numerical artefact.
Is this a bug, or just a handling error by me?
Thanks a lot for your answers,
Kay Frederik Pilz
Kay.Pilz at rub.de
More information about the R-help