On 05/04/2013 16:46, Gerrit Eichner wrote:
Hello, eveRybody,

I've been trying to find the origin for the following
formatting-"inconsistency":

E. g., look at the number of digits in summary.defaults()'s output when
NAs occur: in my example below the number of NA's is displayed as an
integer, the rest as numeric (floating point numbers):

summary.default( c( 1:2, NA))
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's
    1.00    1.25    1.50    1.50    1.75    2.00       1


However, if I define my own summary function using - from my current
point of view - the same commands as the respective part of
summary.default() does, i. e.,

my.summary <- function( object,
                           digits = max( 3, getOption("digits")) - 3) {
   nas <- is.na( object)
   object <- object[ !nas]
   qq <- stats::quantile( object)
   qq <- signif( c( qq[ 1L:3L], mean( object), qq[ 4L:5L]),
                 digits = digits)
   names( qq) <- c( "Min.", "1st Qu.", "Median", "Mean", "3rd Qu.",
                    "Max.")
   v <- if( any( nas)) c( qq, NAs = sum( nas)) else qq
   class( v) <- c("summaryDefault", "table")
   v
   }


I get the following (look at the number of NA's):

my.summary( c( 1:2, NA))
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.     NAs
    1.00    1.25    1.50    1.50    1.75    2.00    1.00


Could somebody please point me to what I'm overlooking?

The print() method for summary.default, and look carefully at the names.


  Thanks & best regards  --  Gerrit

PS:
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] grDevices datasets  splines   graphics  stats     tcltk
utils     methods
[9] base

other attached packages:
[1] xtable_1.7-0     lattice_0.20-10  fortunes_1.5-0   svSocket_0.9-53
[5] TinnR_1.0-5      R2HTML_2.2       Hmisc_3.10-1     survival_2.36-14

loaded via a namespace (and not attached):
[1] cluster_1.14.3 grid_2.15.2    svMisc_0.9-65  tools_2.15.2

---------------------------------------------------------------------
Dr. Gerrit Eichner                   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104          Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109        http://www.uni-giessen.de/cms/eichner

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


--
Brian D. Ripley,                  rip...@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@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.

Reply via email to