[R] Selecting 3 different hours in a day

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue Nov 8 08:54:28 CET 2011

No data sample was provided, so with a verbal description of the problem comes a verbal answer.

I would use expand.grid to build a set of all desired date/time combinations, then use the merge function to select rows in your actual data.
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

jck13 <jennakeane at hotmail.com> wrote:

>I have a csv with 5months of hourly data for 4 years. I would like to
>9am, 12pm and 3pm from each day  and create a subset or a new data
>that I can analyze. The time are from hour 0-23 for each day.
>I am not sure how to create a loop which will take out each of these
>and create a subset.
>I was thinking of doing a for loop using the row number since:
>9am= row 10
>12pm= row 13
>3pm= row 16
>trying to loop through to extract these 3 times each day.
>for (i in i:n) {
>m= 10
>i= 1
>new1= mv[m,]
>i= i+1
>m= m+3
>##m+18 at row 16?
>I need some help creating a loop through this! Thank you! 
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list