? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130717/290a8726/attachment.pl>
truncation and approximation
3 messages · Francesco Miranda, Rui Barradas, alfonso.carfora at uniparthenope.it
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 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.
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 numeric vector containing the integers formed by truncating the values in x
trunc(x)
[1] 3 3 3 3 3 3 3 3 4 I'hope it'is useful to you A.C. Def. Quota Rui Barradas <ruipbarradas at sapo.pt>:
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 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.
______________________________________________ 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.
****************************************************************************** IL MERITO DEGLI STUDENTI VIENE RICONOSCIUTO Il 5 per mille all'Universita' degli Studi di Napoli "Parthenope" incrementa le borse di studio agli studenti - codice fiscale 80018240632 http://www.uniparthenope.it/index.php/5xmille http://www.uniparthenope.it/index.php/it/avvisi-sito-di-ateneo/2943-la-parthenope-premia-il-tuo-voto-di-diploma-ed-il-tuo-imegno-con-i-proventi-del-5-per-mille Questa informativa e' inserita in automatico dal sistema al fine esclusivo della realizzazione dei fini istituzionali dell'ente.