Re: [R] truncation and approximation

2013-07-18 Thread alfonso . carfora
Maybe you can use "round" and "trunc" functions For example if you have a vector like this: x<- c(3.000 3.125 3.250 3.375 3.500 3.625 3.750 3.875 4.000) and you want to round the numbers to 2 decimals you can use: round(x,2) [1] 3.00 3.12 3.25 3.38 3.50 3.62 3.75 3.88 4.00 if you want a n

Re: [R] truncation and approximation

2013-07-17 Thread Rui Barradas
Hello, As for truncation, you can write a one line function: dec_trunc <- function(x, digits = 0) trunc(x * 10^digits)/10^digits As for approximation, maybe you're looking for ?signif. Hope this helps, Rui Barradas Em 17-07-2013 18:41, Francesco Miranda escreveu: What is the function to do