Message-ID: <20020317065730.A23380@cattell.psych.upenn.edu>
Date: 2002-03-17T11:57:30Z
From: Jonathan Baron
Subject: compute variance of every column in a matrix without a loop
In-Reply-To: <3C9410EE.72C67390@lbl.gov>; from FJMolina@lbl.gov on Sat, Mar 16, 2002 at 07:43:42PM -0800
On 03/16/02 19:43, Francisco J Molina wrote:
>Is it possible to compute the variance of every column in a matrix
>without a loop?
If the matrix is m1,
apply(m1,2,var)
or, with missing data,
apply(m1,2,var,na.rm=T)
In general, apply() and related functions are well worth
understanding.
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._