Message-ID: <OFAAC0AB56.3E062796-ONC12578E0.00464E2B-C12578E0.0046736F@precheza.cz>
Date: 2011-08-02T12:48:54Z
From: PIKAL Petr
Subject: Standard Deviation of a matrix
In-Reply-To: <4E37E85E.2050603@knmi.nl>
Hi
> Hi!
>
> The sample below should give you what you want:
>
> M = matrix(runif(100), 10, 10)
> sd(as.numeric(M))
>
> So the as.numeric command is the key. It transforms the matrix to a 1D
> vector. Or alternatively without using as.numeric:
>
> M = matrix(runif(100), 10, 10)
> M
> dim(M) = 100
or dim(M)<-NULL
> M
> sd(M)
>
> Here I use the dim command to set the dimensions to a vector of 100
long.
>
> cheers,
> Paul
>
> On 08/02/2011 11:07 AM, chakri wrote:
> > Hello,
> >
> > My R knowledge could not take me any further, so this request !
> >
> > I have a matrix of dimensions (1185 X 1185). I want to calculate
standard
> > deviation of entire matrix.
> > sd function of {stats} calculates standard deviation for each
row/column,
> > giving 1 X 1185 matrix as result. I would like to have 1 X 1 matrix as
> > result.
> >
> > Any ideas, how to do this ?
> >
> > TIA
> > Chakri
> >
> > --
> > View this message in context: http://r.789695.n4.nabble.com/Standard-
> Deviation-of-a-matrix-tp3711991p3711991.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > R-help at 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.
>
>
> --
> Paul Hiemstra, Ph.D.
> Global Climate Division
> Royal Netherlands Meteorological Institute (KNMI)
> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
> P.O. Box 201 | 3730 AE | De Bilt
> tel: +31 30 2206 494
>
> http://intamap.geo.uu.nl/~paul
> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
>
> ______________________________________________
> R-help at 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.