ANJAN PURKAYASTHA
2009-Oct-03 16:06 UTC
[R] Calculating the average after adding 3 matrices
Hi all, Here is my problem: I have 3 matrices , A, B, C. Each is an nXn matrix. I need to create matrix D such that : D[i,j]= (A[i,j]+B[i,j]+C[i,j])/3. Being a newbie this is proving to be a challenge. Any ideas on how best to accomplish this? Thanks! Anjan -- ============================anjan purkayastha, phd bioinformatics analyst whitehead institute for biomedical research nine cambridge center cambridge, ma 02142 purkayas [at] wi [dot] mit [dot] edu 703.740.6939 [[alternative HTML version deleted]]
Well, yes: add them up and divide by 3. What did you try that didn't work? Sarah On Sat, Oct 3, 2009 at 12:06 PM, ANJAN PURKAYASTHA <anjan.purkayastha at gmail.com> wrote:> Hi all, > Here is my problem: > ?I have 3 matrices , A, B, C. > Each is an nXn matrix. > I need to create matrix D such that : D[i,j]= (A[i,j]+B[i,j]+C[i,j])/3. > Being a newbie this is proving to be a challenge. > Any ideas on how best to accomplish this? > Thanks! > Anjan > >-- Sarah Goslee http://www.functionaldiversity.org
You can just do D<-(A+B+C)/3. Best regards, Ondrej. On 03/10/2009, ANJAN PURKAYASTHA <anjan.purkayastha@gmail.com> wrote:> > Hi all, > Here is my problem: > I have 3 matrices , A, B, C. > Each is an nXn matrix. > I need to create matrix D such that : D[i,j]= (A[i,j]+B[i,j]+C[i,j])/3. > Being a newbie this is proving to be a challenge. > Any ideas on how best to accomplish this? > Thanks! > Anjan > > > -- > ============================> anjan purkayastha, phd > bioinformatics analyst > whitehead institute for biomedical research > nine cambridge center > cambridge, ma 02142 > > purkayas [at] wi [dot] mit [dot] edu > 703.740.6939 > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >[[alternative HTML version deleted]]