[R] Question: Assigning the values of a time series to another one with dif. length and resolution

Daebel Helge Helge.Daebel at eawag.ch
Thu Mar 18 08:36:40 CET 2004


Hi,
I have two time series organized in matixes data.1 and data.2. 
They have different length and resolution.

matrix data.1
t1  v1
t3  v3
t5  v5
...

matrix data.2
t1  0
t2  0
t3  0
...

desired result:
data.2
t1  v1
t2  0
t3  v3
...

What is the MOST EFFECTIVE way (since the matrixes are very large) to assign the values of data.1 to data.2 whenever time values are equal?

Thanks for your help,
Helge

P.S: My solution so far:

for ( i in 1 : nrow(data.1) )
    {
    index  <- which ( data.2[,1] == data.1[i,1] )
    data.2[index,2] <- data.1[i,2]
    }

_________________________________________ 
Swiss Federal Institute for Environmental
Science and Technology (EAWAG)

Dept. of Engineering Sciences

Helge Daebel
EAWAG, ING - CB D35
Ueberlandstrasse 133
CH-8600 Dübendorf, Switzerland

phone: +41 1 823 5052          
fax:   +41 1 823 5389
mail:  helge.daebel at eawag.ch
http:  www.eawag.ch/research_e/ing/uwe/daebel/bivariate_probability.htm




More information about the R-help mailing list