[R] Mean of three inconsistent curves

Loenn2010 dominik.stangler at iww.uni-freiburg.de
Mon May 30 15:50:39 CEST 2011


Hello,

I have a dataframe with e.g. three different curves (columns), which I want
to have averaged.
I use the row.Means function, which is working good. However as I have a
time series,
some parts of the three columns have sometimes NA. I want however that if
only one or two columns
are available, the level of the averaged column value does not suddenly rise
or fall, because one column in missing.

Is there maybe already a syntax available for it? I would like to calculate
an average of all curves, but in those cases where I have only two or less
columns, just use those but still try to get a harmonized curve.

Here are my three columns. The fourth one is the averaged one. I want that
row 7534 continues with 1086.77... and that the difference, due to the
reduction of "N" is calculated and removed automatically.

Row number
7532                      900                 1479.00               
877.0000 1085.3333333
7533                      901                 1482.00               
877.3375 1086.7791667
7534                      903                 1482.00                     
NA 1192.5000000
7535                      904                 1486.00                     
NA 1195.0000000
7536                      905                 1487.00                     
NA 1196.0000000

Same if third columns is coming back:

Row number
8832                     1471                 2172.00                     
NA 1821.5000000
8833                     1463                 2173.00              
1242.0000 1626.0000000

Any ideas or help is really appreciated.

Regards
Loenn

--
View this message in context: http://r.789695.n4.nabble.com/Mean-of-three-inconsistent-curves-tp3560788p3560788.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list