Have you gone thruway any T tutorials yet? This is a very basic question
that I do not believe would arise if you had done so.

The answer is that it is a logical that controls whether means and sd's or
medians and mads are calculated and returned. But I don't think this answer
will be comprehensible if you asked the question in the first place. Some
minimum effort must be made to learn the language details to understand
even simple function code.

Cheers,
Bert

On Tuesday, April 21, 2015, Luciano La Sala <lucianolas...@yahoo.com.ar>
wrote:

> 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
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>


-- 

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge is
certainly not wisdom."
Clifford Stoll

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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