[R] Best way to do temporal joins in R?

jim holtman jholtman at gmail.com
Fri Apr 6 19:04:45 CEST 2012


check out the 'sqldf' package.  In
http://code.google.com/p/sqldf/#Example_4._Join there is an example of
a temporal join.  Maybe this will work for you.

On Fri, Apr 6, 2012 at 9:56 AM, Edith Mertz <mertz.em at gmail.com> wrote:
> Found the blunder, last line should have been:
>
> TideH$dt <- as.chron(paste(TideH$Date, TideH$Time), "%Y%m%d %H%M%S")
>
> After this I did:
>
> Fix <- read.csv("Fix times.csv")
> Fix[,"Station"] <- as.character(Fix[,"Station"])
> Fix[,"Date"] <- as.Date(Fix[,"Date"],format="%d/%m/%Y")
> Fix[,"Time"] <- as.character(Fix[,"Time"])
> Fix[,"Fix.Type"] <- as.character(Fix[,"Fix.Type"])
>
> Fix$DateTime<- as.chron(paste(Fix$Date, Fix$Time), "%Y%m%d %H%M%S")
>
> ds <- Fix$DateTime
> Fix$dt <- chron(sub(" .*", "", ds), gsub("[apm]+$|^.* ", "", ds)) +
>  (regexpr("pm", ds) > 0)/2
>
> Which gave an error list:
>
> Error in convert.dates(dates., format = format[[1]], origin. = origin.) :
>  format m/d/y may be incorrect
> In addition: Warning messages:
> 1: In unpaste(dates., sep = fmt$sep, fnames = fmt$periods, nfields = 3) :
>  17955 entries set to NA due to wrong number of fields
> 2: In convert.dates(dates., format = format[[1]], origin. = origin.) :
>  NAs introduced by coercion
> 3: In convert.dates(dates., format = format[[1]], origin. = origin.) :
>  NAs introduced by coercion
> 4: In convert.dates(dates., format = format[[1]], origin. = origin.) :
>  NAs introduced by coercion
>
> Now I'm lost 4sure, help?
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Best-way-to-do-temporal-joins-in-R-tp885420p4537443.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.



More information about the R-help mailing list