[R] Standard Deviation of a matrix

2011-08-02 Thread chakri
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

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread Paul Hiemstra
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 M sd(M) Here I use the

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread Petr PIKAL
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

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 8:48 AM, Petr PIKAL wrote: 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 =

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread chakri
Thank you everyone for your kind input, I forgot to add that I have decimal points in my matrix ! Enclosed input file (reduced to 10 X 10 matrix), scripts and output for your suggesions: Code 1: library(stats) Matrix-read.table(test_input, head=T, sep= , dec=.) SD-sd(as.numeric(Matrix)) SD

Re: [R] Standard Deviation of a matrix

2011-08-02 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of chakri Sent: Tuesday, August 02, 2011 6:31 AM To: r-help@r-project.org Subject: Re: [R] Standard Deviation of a matrix Thank you everyone for your kind input, I forgot