I have dataframe A
structure(list(gauge = c(1094000L, 1094000L, 1094000L, 1100600L
), start = structure(c(2L, 4L, 1L, 3L), .Label = c("4/16/2007 18:45",
"4/2/2004 12:45", "4/24/2012 9:15", "5/14/2006 21:00"), class = "factor")), .Names = c("gauge",
"start"), row.names = c(NA, 4L), class = "data.frame")
And another dataframe B with timestamps
structure(list(Time = structure(1:20, .Label = c("2002-01-01 00:00",
"2002-01-01 00:05", "2002-01-01 00:10", "2002-01-01 00:15", "2002-01-01 00:20",
"2002-01-01 00:25", "2002-01-01 00:30", "2002-01-01 00:35", "2002-01-01 00:40",
"2002-01-01 00:45", "2002-01-01 00:50", "2002-01-01 00:55", "2002-01-01 01:00",
"2002-01-01 01:05", "2002-01-01 01:10", "2002-01-01 01:15", "2002-01-01 01:20",
"2002-01-01 01:25", "2002-01-01 01:30", "2002-01-01 01:35"), class = "factor"),
Precip.mm.h..1. = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0)), .Names = c("Time", "Precip.mm.h..1."
), row.names = c(NA, 20L), class = "data.frame")
I want to
- Read the time from A
- Find the exact time in B and it's row number
- Find corresponding Precip value in B
Using lubridate, I converted timestamp in A to UTC:
A$startTime <-mdy_hm(A$start)
But I am not sure how to compare two timestamps.
P.S. B is a really large file with a million rows. So I wasn't able to give you corresponding data for A.