Re: [R] convert character vector to decimal for numeric testing

2015-07-15 Thread jim holtman
It does round to 3 digits, but since the last one is a zero, is only prints 5.43 and not 5.430. Why do you want the last zero? Is this going into a report or something? You can always use sprintf: > x <-round(5.43, 3) > x [1] 5.43 > sprintf("%.3f", x) [1] "5.430" > BTW you are converting your

[R] convert character vector to decimal for numeric testing

2015-07-15 Thread Luigi Marongiu
Dear all, I have a vector that comes from some calculations I am making and this vectors turns out to be in character format rather than numerical. I can convert it in numerical format but then the calculations are not correct, as you can see in the following example. I was also expecting that roun