[R] Best way to do temporal joins in R?
Edith Mertz
mertz.em at gmail.com
Fri Apr 6 14:52:54 CEST 2012
Hi, I'm new to R-help mailing list and novice in R, so pls excuse 'silly
questions' and obvious blunders.
I have the same problem as Jon Greenberg (just different data) and have been
trying to use the code given above, but with some difficulty.
Pls Help?
My data:
Table 1 (TideH.csv)
Date Time Tide Height
03/02/2010 08:00:00 1.9
03/02/2010 09:00:00 1.49
03/02/2010 10:00:00 1.04
Table 2 (Fix times.csv)
Station Date Time Fix Type
1 03/02/2010 09:20:30 Mn
1 03/02/2010 09:23:27 Mn
1 03/02/2010 09:32:05 Mn
Need to get tide height values /nearest/ to the fix time.
Result should be:
Station Date Time Fix Type Tide Height
1 03/02/2010 09:20:30 Mn 1.49
1 03/02/2010 09:23:27 Mn 1.49
1 03/02/2010 09:32:05 Mn 1.04
This is what I have tried so far:
library(chron)
TideH <- read.csv("TideH.csv")
TideH[,"Date"] <- as.character(TideH[,"Date"])
TideH[,"Date"] <- as.Date(TideH[,"Date"],format="%d/%m/%Y")
TideH[,"Time"] <- as.character(TideH[,"Time"])
TideH[,"Tide.Height"] <- as.numeric(TideH[,"Tide.Height"])
TideH$dt <- as.chron(paste(TideH$date, TideH$time), "%Y%m%d %H%M%S")
Error in `$<-.data.frame`(`*tmp*`, "dt", value = numeric(0)) :
replacement has 0 rows, data has 3
What went wrong?
--
View this message in context: http://r.789695.n4.nabble.com/Best-way-to-do-temporal-joins-in-R-tp885420p4537342.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list