[R] calculation on series with different time-steps

Jannis bt_jannis at yahoo.de
Tue Jul 6 00:51:53 CEST 2010


Your question seem to me to be not precise enough for us to provide 
help. Do you need help with the if() syntax? If yes I would advice you 
to read some introductory R tutorial (like "introduction to R" (pdf, 
freely avalable on the net)) or some descent textbook.

On quick hint for the correct syntax:
 | denotes OR
& denotes AND
you need to write == if you want to use the logical "equals"

If you do not know how to write the results to some dataframe you should 
really invest the time to get to know to R by some basic tutorial to 
understand the basics.

By the way, if your timeseries is ordered in the way you describe, a 
more elegant way would be to create a series consisting of the pressure 
value belonging to each entry in the stream stage vector (by repeating 
each single value of pressure 12 times (see ?rep ), and then just 
substract the two.


HTH
Jannis

Jeana Lee schrieb:
> Hello,
>
> I have two series, one with stream stage measurements every 5 minutes, and
> the other with barometric pressure measurements every hour.  I want to
> subtract each barometric pressure measurement from the 12 stage measurements
> closest in time to it (6 stage measurements on either side of the hour).
>
> I want to do something like the following, but I don't know the syntax.
>
> "If the Julian day of the stage measurement is equal to the Julian day of
> the pressure measurement, AND the absolute value of the difference between
> the time of the stage measurement and the hour of the pressure measurement
> is less than or equal to 30 minutes, then subtract the pressure measurement
> from the stage measurement (and put it in a new column in the stage data
> frame)."
>
>                      if ( stage$julian_day = baro$julian_day & |stage$time -
> baro$hour| <= 30 )
>                      then (stage$stage.cm - baro$pressure)
>
> Can you help me?
>
> Thanks,
> JL
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list