Reputation: 119
In R I am using the min function on a vector of numeric values, like this vector:
v <- c(16.22900, 16.28857, 16.47363, 16.47412, 16.00000, 16.49463, 16.27246, 16.0366, 16.49609)
However when I apply the min function, I get this return value
min(v)
[1] 16
instead I would like this result:
[1] 16.00000
I checked the class of the vector but all seems ok
class(v)
[1] "numeric"
Where is the problem?
Upvotes: 1
Views: 1215
Reputation: 368301
You are caught between internal representation of a value and how it is displayed.
R> v <- c(16.22900, 16.28857, 16.47363, 16.47412, 16.00000,
+ 16.49463, 16.27246, 16.0366, 16.49609)
R> min(v)
[1] 16
R> sprintf("%10.8f", min(v))
[1] "16.00000000"
R> identical(min(v), 16.0000000000000000000)
[1] TRUE
R>
Upvotes: 2