[R] Selecting 3 different hours in a day

Jim Holtman jholtman at gmail.com
Tue Nov 8 12:24:57 CET 2011


attach another column to you dataframe with the hour of the day and then use 'subset' to collect the three hours of interest.

Sent from my iPad

On Nov 8, 2011, at 1:12, jck13 <jennakeane at hotmail.com> wrote:

> Hello,
> 
> I have a csv with 5months of hourly data for 4 years. I would like to get
> 9am, 12pm and 3pm from each day  and create a subset or a new data frame
> 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 hours
> 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.
> 
> n=length(date_stamp)
> 
> 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: http://r.789695.n4.nabble.com/Selecting-3-different-hours-in-a-day-tp4015010p4015010.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.



More information about the R-help mailing list