Skip to content

Descriptive statistics for tables

5 messages · DAVID CAMACHO, Bert Gunter, Jean Eid +1 more

#
I don't know what a "quadratic, same size" table is or what you mean. If you
do not get a satisfactory reply I suggest:

1. Read and follow the posting guide at the end of this message.

2. In particular, provide a simple, reproducible example to show what you
want to do and perhaps any error messages that you may have received.


-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
7 days later
#
Thanks for your response,

What I need is extremely simple. And I suppose there
are so many way to do it.
But as I have so many files to do it, I am looking for
the simplest way (if possible)

What I meant was that I have tables with the same
numbers of rows and columns, (square form, should I
say?) like:

2,5,7
3,4,8
2,9,3

5,3,8
2,5,5
5,7,8

But I have hundreds of this onces, (bigger once).
Every one of this tables have the same size (columns,
rows). And I want to obtain the sd, z-score, and
p-value for the position [1,1], [1,2]....
[2,1],[2,2]... etc etc. That is, to obtain a table
with some simple descriptive statistics about all this
tables. 
I have try different methods, but I am no familiar
with R. (by the way, I could not find the way to do
loops with R)
Any suggestion is welcome.
David
--- Berton Gunter <gunter.berton at gene.com> wrote:

            
#
I do not totally understand your question as well. You seem to want a
descriptive statistic about a unitary number. What is the sd of a number?
or any other descriptive statictic. Maybe you mean for the columns or rows
or it could be that these are t-stats or z-stats that you need to get
p_values for them. In any case what I would do assuming that these tables
are in your env is the following

sapply(ls(), function(x){
  nam <- paste(x,"_summary", sep="")
  tt <- colMeans(get(x))
  assign(nam, tt, pos=1)})

The function above will output a number of tables with their original name
an extension _summary which contains the column means of the tables.

If you have the tables in different files on your box you need to add a
read.table line above. and the function becomes

sapply(dir(), function(x){

  nam <- paste(x,"_summary", sep="")
  assign(x, read.table(x))
	tt <- colMeans(x)
  assign(nam, tt, pos=1)})


HTH
On Fri, 30 Sep 2005, DAVID CAMACHO wrote:

            
#
If I understand the request, he wants to take a large number of matrices 
of identical size and stack them into a three dimentional array, and 
then calculate statistics on the the third dimension.   If the multiple 
arrays have object names they can be combined into a 3-d array

 > a <- matrix(rep(1,9),ncol=3)
 > b <- matrix(rep(2,9),ncol=3)
 > c <- matrix(rep(3,9),ncol=3)
 > z <- array(c(a,b,c),dim=c(3,3,3))

 > z
, , 1

      [,1] [,2] [,3]
[1,]    1    1    1
[2,]    1    1    1
[3,]    1    1    1

, , 2

      [,1] [,2] [,3]
[1,]    2    2    2
[2,]    2    2    2
[3,]    2    2    2

, , 3

      [,1] [,2] [,3]
[1,]    3    3    3
[2,]    3    3    3
[3,]    3    3    3


and then specific dimensions can be summarized

 > mean(z[1,1,])
[1] 2

 > sd(z[1,1,])
[1] 1

I don't know of any easy way to combine all the 2-d matrices other than 
listing them by name in a c() function in the array statement.  If they 
were cleverly names perhaps a for loop could be used.

Dave
Jean Eid wrote: