[R] How to repeat for function?

2010-02-01 Thread ayu2008
Dear Users, I have one problem here, I tried many time and even read a few notes on writing function but still. Can anyone help me on how to simplify Part B (please refer the programming below), so that I don't have to repeat the calculation of num and r ? Thank you very much..every

Re: [R] Odp: How to repeat for function?

2010-02-01 Thread ayu2008
Dear Petr, The intention is to get a ratio value for every observations (1400 obs) for every variable (4 variables). And from the ratios, I would like to rank the variables based on how many times the variable being the highest among 4 of them (or the total number of being the highest

[R] How to split a matrix into a few matrices?

2010-01-27 Thread ayu2008
Hi dear users, I try to split a matrix into a few matrices, for example, suppose that I have 1000X4 matrix from mvrnorm(1000,m,c) with m-matrix(c(0,0,0,2),4,1) and c-matrix(c(1.0,0.2,-0.5,0.3,0.2,1,0.2,-0.5,-0.5,0.2,1,0.2,0.3,-0.5,0.2,1),4,4,byrow=T) How to split the matrix into a. 2