Re: [R] Number of digits in paste funciton

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 18 Jun 2008 09:53:27 +0100 (BST)

On Wed, 18 Jun 2008, Tine wrote:

> Hi!
>
> Does anyone know hot to set number of digits to be printed in function
> 'paste'?

paste() does not print, so we can only guess at what you mean. The help says

      'paste' converts its arguments (_via_ 'as.character') to character
      strings, and concatenates them (separating them by the string
      given by 'sep').

So I guess you are talking about conversion by as.character. And its help says

     'as.character' represents real and complex numbers to 15
      significant digits (technically the compiler's setting of the ISO
      C constant 'DBL_DIG', which will be 15 on machines supporting
      IEC60559 arithmetic according to the C99 standard).  This ensures
      that all the digits in the result will be reliable (and not the
      result of representation error), but does mean that conversion to
      character and back to numeric may change the number.  If you want
      to convert numbers to character with the maximum possible
      precision, use 'format'.

and format() seems to be what you too are looking for (or sprintf or formatC).

>
> Tine Mlač
>
> ______________________________________________
> R-help@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.
>
PLEASE do at least read the help before posting, as the posting guides asks of you.

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


______________________________________________ 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.

Received on Wed 18 Jun 2008 - 08:58:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 18 Jun 2008 - 09:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive