[R] Mean and Timeseries modelling

Marko markho1984 at googlemail.com
Fri Jul 22 11:28:51 CEST 2011


Hello,
i have following problem and I hope you can help me a little bit


My dataframe looks like:

df
a       m  d   typ    value
1950  1  1    5      -4.1
1950  1  2    9       2.7
1950  1  3    3      -1.3
1950  1  4    5      -1.9
1950  1  5    2       0.2
1950  1  6    8       0.5
1951  1  1    4       1.3
....

It consists by daily observations from 1950- 2009.

Now, I get with....

for (i in df$V5)
neu <- tapply(df[,5],list(df$V4,df$V1),mean)

the yearly means of the types (1-18) for every year.

The new df looks like:

new
typ       1950       1951       1952        1953        1954        1955        
1956            ...       2009
1   0.40588235 -0.1714286 -1.8111111   5.4000000  -0.9555556  2.65833333
2  -3.17777778  1.4130435 -0.9166667  -4.9000000   0.2900000  3.54285714
3   0.08888889 -2.0000000 -2.9666667   2.2000000  -1.8600000 -0.50000000
...
18


Now, i would like to generate a timeseries with the means, according to the
different types.
For example: For all days in the year 1950 with the typ 1, I would like to
write the mean value for Typ 1 in year 1950. In year 1951 I would like to
write the mean value for typ 1 in 1951 etc. (for all 18 types)

The output should look like as following:

erg
a       m  d   typ    value   mean_typ_year
1950  1  1    1      -4.1      0,4
1950  1  2    2       2.7      Mean (Typ2 1950)
1950  1  3    1      -1.3      0,4
1950  1  4    5      -1.9      Mean (Typ5 1950)
1950  1  5    2       0.2      ...
1950  1  6    8       0.5      ...
1951  1  1    1       1.3      -0,17
1951  1  2    2       2.1      Mean (Typ2 1951)
....

I hope you can help me by solving this problem 

Best regards,
Marko

--
View this message in context: http://r.789695.n4.nabble.com/Mean-and-Timeseries-modelling-tp3686326p3686326.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list