try this:
> mydata <- matrix(runif(5000),ncol=5)
> indices <- list(c(173, 193),
+ c(434, 455),
+ c(699, 724),
+ c(955, 977))
> result <- lapply(indices, function(.indx){
+ mean(mydata[.indx[1]:.indx[2], 5])
+ })
>
>
> result
[[1]]
[1] 0.5364535
[
t; From: Edouard Tallent
> Subject: [R] how to create a simple loop ?
> To: r-help@r-project.org
> Received: Sunday, December 27, 2009, 9:15 AM
> Hi everyone. And, Merry Xmas !
> I have a 5-row matrix called “data”. There are
> headers.
> it look
On Dec 27, 2009, at 9:15 AM, Edouard Tallent wrote:
Hi everyone. And, Merry Xmas !
I have a 5-row matrix called “data”. There are headers.
it look like this :
Row 1 Row2Row3Row4Row5
Line1 …………
Line2 ………
Hi everyone. And, Merry Xmas !
I have a 5-row matrix called âdataâ. There are headers.
it look like this :
Row 1 Row2Row3Row4Row5
Line1 â¦â¦â¦â¦
Line2 â¦â¦â¦â¦
Line3 â¦â¦
I have a 5-row matrix called âdataâ. There are headers.
it look like this :
Row 1 Row2Row3Row4Row5
Line1 â¦â¦â¦â¦
Line2 â¦â¦â¦â¦
Line3 â¦â¦â¦â¦
â¦
L
5 matches
Mail list logo