[R] truncation and approximation

Rui Barradas ruipbarradas at sapo.pt
Wed Jul 17 21:31:38 CEST 2013


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 the truncation to a certain decimal digit of a number. And the function approximation? 		 	   		
> Thanks.
> Francesco M 		 	   		
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list