[R] Question on funcion and npar

Luciano La Sala lucianolasala at yahoo.com.ar
Tue Apr 21 20:05:28 CEST 2015


Dear everyone,

The following function, taken from Quick-R, gets measures of central 
tendency and spread for a numeric vector x.

I can't figure out what the argument npar means in each instance.
Any tips will be most appreciated.

mysummary <- function(x, npar=TRUE, print=TRUE) {
   if (!npar) {
     center <- mean(x); spread <- sd(x)
   } else {
     center <- median(x); spread <- mad(x)
   }
   if (print & !npar) {
     cat("Mean=", center, "\n", "SD=", spread, "\n")
   } else if (print & npar) {
     cat("Median=", center, "\n", "MAD=", spread, "\n")
   }
   result <- list(center=center,spread=spread)
   return(result)
}


-- 
Luciano F. La Sala
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
Cátedra de Epidemiología
Departamento de Biología, Bioquímica y Farmacia
Universidad Nacional del Sur
San Juan 670
Bahía Blanca (8000)
Argentina



More information about the R-help mailing list