Dear all, I am new to programming in R. I deal with microarray data,which is a data frame object type. I need to carry out a few statistical procedures on this, one of them being the pearson corelation. I need to do this between each row which is a gene. So the desired result is a square matrix with the pearson corelation value between each row. So the first column would be (1,1)=0,(1,2),(1,3) and so on.
I uploaded the data frame as "a":- a <- read.csv("a.csv", header= TRUE, row.names=1) and then I started the script:- pearson <- function(a){ r <- matrix[x,y] for(x in as.vector(a[,1], mode="double")){ x++{ for(y in as.vector(a[2,], mode="double")){ y <- x+1 x++ { r <- (cor.test(as.vector(as.matrix(a)[x,], mode="double"), as.vector(as.matrix(a)[y,], mode="double"))$p.value) } } } r[x,y]==r[y,x] } return(r) } However whenever I run it,I get the error:- > pearson(a) Error in matrix[x, y] : object of type 'closure' is not subsettable Please help! Best Regards Sumona Mitra ______________________________________________ R-help@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.