On May 15, 2013, at 11:24 PM, Pascal Oettli wrote:

> Hi,
> 
> You probably should read R documentation and learn how to use "seq"
> 
> ?seq
> ?rowMeans
> 
> HTH,
> Pascal
> 
> 
> On 05/16/2013 03:17 PM, Zilefac Elvis wrote:
>> Hello,
>> 
>> I need your help on this matrix:
>> 
>> 
>>  1 1 1 1 1 1
>>  2 2 2 2 2 2
>>  3 3 3 3 3 3
>>  5 5 5 5 5 5
>>  2 2 2 2 2 2
>>  3 3 3 3 3 3
>>  6 6 6 6 6 6
>>  2 2 2 2 2 2
>>  3 3 3 3 3 3
>>  1 1 1 1 1 1
>>  2 2 2 2 2 2
>>  3 3 3 3 3 3
>> 
>> First three rows represent first simulation, next three rows = second 
>> simulation etc.
>> I would like to estimate the values in row 1 for example by taking  the mean 
>>  of rows 1, 4, 7, 10. Do same for all other rows. So the resulting matrix is
>> 3-by-6.

It seems from the dimensions expected that what your really want is not means 
of rows but rather means of columns.

matrix( c( colMeans( sim[c(TRUE,FALSE,FALSE), ]), # recycling picks out 
1,4,7,10, ...
 colMeans( sim[c(FALSE,TRUE,FALSE), ]),
 colMeans( sim[c(FALSE,FALSE,TRUE), ])), ncol=6, byrow=TRUE)

-- 
David Winsemius
Alameda, CA, USA

______________________________________________
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.

Reply via email to