[R] round() a data frame containing 'character' variables?

Liviu Andronic landronimirc at gmail.com
Thu Aug 11 19:50:52 CEST 2011


Hello

On Thu, Aug 11, 2011 at 4:34 PM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
> Well, as you say it's  "View()" only, so why don't you just
> "view" the result of
>
> something like
>          print(<data>, digits = 2)
>
Unfortunately print(..., digits = 2) suffers of the same deficiencies
as format(..., digits = 2): they both display a "minimal number of
_significant_ digits". What I would need, however, is to specify the
"number of decimal places" as in round(..., digits = 2).


> (it does correspond to  signif(), rather than round(),
>  but I think that that's more sensible anyway).
>
Although I do appreciate the rationale behind ?signif, for several
subjective reasons---easiness of inspecting round()-ed data or
aesthetics in printing round()-ed data in Sweave (as in "I cannot send
format()-ed data to my advisor")---I would prefer to ?round my data.

Is there any chance that 'base' would feature a round() function that
doesn't stumble when processing non-numeric data (simply by ignoring
it), or a format() or print() function with a 'round=NULL' argument?

Regards
Liviu



More information about the R-help mailing list