[R] Standard Deviation of a matrix
chakri
chakri2sai at yahoo.co.in
Tue Aug 2 15:30:33 CEST 2011
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
Output 1:
> library(stats)
> Matrix<-read.table("test_input", head=T, sep="\t", dec=".")
> SD<-sd(as.numeric(Matrix))
Error in sd(as.numeric(Matrix)) :
(list) object cannot be coerced to type 'double'
Execution halted
Code 2:
library(stats)
Matrix<-read.table("test_input", head=T, sep="\t", dec=".")
dim(Matrix)<-1
SD<-sd(Matrix)
SD
Output:
> library(stats)
> Matrix<-read.table("test_input", head=T, sep="\t", dec=".")
> dim(Matrix)<-1
Error in dim(Matrix) <- 1 :
dims [product 1] do not match the length of object [10]
Execution halted
Code 3:
library(stats)
Matrix<-read.table("test_input", head=T, sep="\t", dec=".")
SD<-sd(c(Matrix))
SD
Output:
> library(stats)
> Matrix<-read.table("test_input", head=T, sep="\t", dec=".")
> SD<-sd(c(Matrix))
Error: is.atomic(x) is not TRUE
Execution halted
Any ideas, what am I missing here ?
TIA
chakri
Input file: http://r.789695.n4.nabble.com/file/n3712328/test_input
test_input
--
View this message in context: http://r.789695.n4.nabble.com/Standard-Deviation-of-a-matrix-tp3711991p3712328.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list