Try this:
# First read in the data using chron "times" class
Lines.Bary <- "X Y Date Time
Depth
-2.620748 48.75121 01/00/00 12:07:16.000 -25.6
-2.620714 48.75121 01/00/00 12:07:17.000 -25.8
-2.620698 48.75121 01/00/00 12:07:17.000 -26.0
-2.620682 48.75121 01/00/00 12:07:18.000 -26.1
-2.620667 48.75121 01/00/00 12:07:18.000 -26.1"
Lines.Depth <- "
Time Correction
11:55:07.58 -2.64
11:55:07.68 -2.64
11:55:07.88 -2.64
11:55:08.28 -2.64
11:55:08.38 -2.64"
library(chron)
DF.Depth <- read.table(textConnection(Lines.Depth), header = TRUE, as.is =
TRUE)
DF.Depth$Time <- times(DF.Depth$Time)
DF.Bary <- read.table(textConnection(Lines.Bary), header = TRUE, as.is =
TRUE)
DF.Bary$Time <- times(DF.Bary$Time)
# Now perform the calculation using findInterval
DF.Bary$Depth <- DF.Bary$Depth +
DF.Depth[findInterval(DF.Bary$Time, DF.Depth$Time), "Correction"]
On Mon, Jul 13, 2009 at 6:11 AM, Poizot Emmanuel<emmanuel.poizot at
cnam.fr> wrote:> Dear all,
>
> I want make correction depth of a bathymetric data set.
> To do so, I have the depth data set sample every second (a depth at each
> second) in one hand, and in the other hand, I have a tide variation level
> data set sample every 250 ms. The time register in each data sets (tide and
> bathymetric) is express in seconds followinf this format : hh:mm:ss.ss
> I would like to rectify the depth (bathymetry) by substrating the tide at
> each depth time.
> I tried to construct time series using pastecs package but didn't
succed
>
> Example of the tide data set:
> Time ? ? ? ? ? ? Correction
> 11:55:07.58 ?-2.64
> 11:55:07.68 ?-2.64
> 11:55:07.88 ?-2.64
> 11:55:08.28 ?-2.64
> 11:55:08.38 ?-2.64
>
> Example of the bathymetric data:
> X ? ? ? ? ? ? ? ?Y ? ? ? ? ? ? Date ? ? ? Time ? ? ? ? ? ? ?Depth
> -2.620748 48.75121 01/00/00 12:07:16.000 -25.6
> -2.620714 48.75121 01/00/00 12:07:17.000 -25.8
> -2.620698 48.75121 01/00/00 12:07:17.000 -26.0
> -2.620682 48.75121 01/00/00 12:07:18.000 -26.1
> -2.620667 48.75121 01/00/00 12:07:18.000 -26.1
>
> How can I construct the time series based on that two data sets allowing me
> then to to the depth rectification ?
> Regards
>
> --
> Cordialement
>
> ------------------------------------------------
> Emmanuel Poizot
> Cnam/Intechmer
> B.P. 324
> 50103 Cherbourg Cedex
>
> Phone (Direct) : (00 33)(0)233887342
> Fax : (00 33)(0)233887339
> ------------------------------------------------
>
>
> ______________________________________________
> 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.
>
>