[R] Loop to find dates whithin dates

jim holtman
2011-02-07T17:53:03Z

If you are looking to find out if a given GPS time is between
sunrise/sunset, then here is what I would do given the quantity of
data.  I would encode the sunrise/sunset times in a character vector
of length 10 years * 365 days/year * 1440 minutes/day = 5M character
vector.  Set the vector to '1' if between the times.  Now all you have
to do is convert you GPS times to an index into this vector and if it
is '1' then you know that you are between sunrist/sunset.  Saves
having to compare each GPS time to the 3650 entries in you database.

On Mon, Feb 7, 2011 at 9:10 AM, patraopedro <patraopedro at yahoo.com.br>
wrote:
>
> Hello to all,
>
> I have two dataframes, the first with two columns sunrise and sunset (for
10
> years). Each of these columns is formatted for date time (ex: 01-Jan-2010
> 15:37:00)
>
> In the second data frame I have GPS information and also a date time column
> (same format ).
>
> What I would like to do is a subset of all the rows from the second
> dataframe that occurred in day time only so between sunrise and sunset.
> There are thousands of lines from multiple GPS so date time might be
> repeated in some rows.
>
> Any ideas how to accomplish this?
>
> Thanks in advance
>
> Patrao
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Loop-to-find-dates-whithin-dates-tp3264180p3264180.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?