[R] mean duration (persistence) of daily data

2010-06-20 Thread Schmidt Martin
Dear R users A quite simple question: how can I get the mean duration (persistence) of daily data, when the data set looks as follows:  [1] 7 7 7 9 9 5 7 5 5 5 9 5 5 6 6 6 1 1 1 2 2 4 4 4 4 7 7 3 3 2 4 4 7 7 7 7 7 [38] 7 7 5 5 9 9 5 5 5 1 7 9 9 9 9 9 5 5 5 5 5 3 4 4 4 4 4 4 4 4 2 2 2 2 2 2 8

[R] cut out single lines out of matrix

2010-03-16 Thread Schmidt Martin
Hey dear users I'm trying to kind of split my matrix which looks as follows: dim(out) [1] 30 12 What I finally want is each line as it's own matrix which I can handle then separately. Like, say: out1<- [1,] out2<-[2,] .. Would you do that with a for() loop or does exist an other approp

[R] for() loop

2010-03-14 Thread Schmidt Martin
Hello I'm working with R since a few month and have still many trivial questions - I guess! Here is what I want: I have this matrix: dim(datjan) [1] 899 4 The first 10 rows looks as follows: datjan[1:10,] V1 V2 V3 V4 1 1961 1 1 24 2 1961 1 2 24 3 1961 1 3 24 4 1961 1 4