[R] How to average outputs

From: Dat Mai <dat.d.mai_at_gmail.com>
Date: Thu, 28 Apr 2011 11:43:13 -0400


Hello,

I am trying to create a matrix that generates an output from 2 inputs. The problem I have is that I'm assigning a large set of data to various categories (that are used for the matrix). This technically means that I will have multiple output values for each unique set of inputs--I want to average the values of the output. How would I do so?

n=length(b$largedataset)
for(j in 2:n){
  for(i in 1:(j-1)){

    input1=rownames(m)[i]
    input2=rownames(m)[j]

    q=t[(t$category1==input1 & t$category2==input2),output]

    if(length(q)==0){
      q=t[(t$category1==input2 & t$category2==input1),output]     }

    m[i,j]=q
    m[j,i]=q
  }
}

I've only got up to here and don't know how to continue.

        [[alternative HTML version deleted]]



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. Received on Thu 28 Apr 2011 - 16:46:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Apr 2011 - 16:50:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive