Re: [R] Loop to find dates whithin dates

2011-02-10 Thread Phil Spector
I can't see a good solution using a loop, but perhaps this will get you what you want: Dframe1$date = as.Date(Dframe1$sunrise) Dframe2$date = as.Date(Dframe2$Logtime) both = merge(Dframe1,Dframe2) both$when = ifelse(both$Logtime >= both$sunrise & +both$Logtime <= both$sunse

Re: [R] Loop to find dates whithin dates

2011-02-08 Thread patraopedro
I would like to thank you all for your suggestions. Bill yours work’s like a charm and your first code was very useful as well. JHoltman, great idea that’s what I call thinking outside of the box. Once again thank you for all the help Patrao -- View this message in context: http://r.789695.n

Re: [R] Loop to find dates whithin dates

2011-02-07 Thread William Dunlap
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of patraopedro > Sent: Monday, February 07, 2011 9:36 AM > To: r-help@r-project.org > Subject: Re: [R]

Re: [R] Loop to find dates whithin dates

2011-02-07 Thread patraopedro
Thank you for your responses but I think whith some examples the problem will be better understated. Ok, here it is an example of how the data looks like to allow a better understanding of the problem. Dframe1 <- data.frame(sunrise = seq(as.POSIXct("2010-07-14 06:05:25"),as.POSIXct("2010-07-20 0

Re: [R] Loop to find dates whithin dates

2011-02-07 Thread jim holtman
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' i

Re: [R] Loop to find dates whithin dates

2011-02-07 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Eik Vettorazzi > Sent: Monday, February 07, 2011 9:26 AM > To: patraopedro > Cc: r-help@r-project.org > Subject: Re: [R] Loop to find dates whithin dates

Re: [R] Loop to find dates whithin dates

2011-02-07 Thread Eik Vettorazzi
Hi Patrao, you can 'merge' both datasets using the (extracted) day as indicator, see ?merge. Then use subset. hth. Am 07.02.2011 15:10, schrieb patraopedro: > > Hello to all, > > I have two dataframes, the first with two columns sunrise and sunset (for 10 > years). Each of these columns is for

Re: [R] Loop to find dates whithin dates

2011-02-07 Thread Daniel Nordlund
?subset Daniel Nordlund Bothell, WA USA > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of patraopedro > Sent: Monday, February 07, 2011 6:11 AM > To: r-help@r-project.org > Subject: [R] Loop to find d

[R] Loop to find dates whithin dates

2011-02-07 Thread patraopedro
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