[R] Subsetting Timestamped data

arun smartpink111 at yahoo.com
Fri Oct 4 21:14:53 CEST 2013


May be this helps:

df1<- data.frame(datetime=as.POSIXct("2011-05-25",tz="GMT")+0:200*30*60,value=sample(1:40,201,replace=TRUE),value2= sample(45:90,201,replace=TRUE))
 df2<- df1[ave(1:nrow(df1),as.Date(df1[,1]),FUN=length)==48,]
#[1] 192   3

#[1] TRUE


----- Original Message -----
From: "aj409 at bath.ac.uk" <aj409 at bath.ac.uk>
To: r-help at r-project.org
Sent: Friday, October 4, 2013 11:03 AM
Subject: [R] Subsetting Timestamped data


I have a data frame, data, containing two columns: one- the TimeStamp  
(formatted using data$TimeStamp <-  
as.POSTIXct(as.character(data$TimeStamp), format = "%d/%m/%Y %H:%M") )  
and two- the data value.

The data frame has been read from a .csv file and should contain 48  
values for each day of the year (values sampled at 30 minute  
intervals). However, there are only 15,948 observations i.e. only  
approx 332 days worth of data. I therefore would like to remove any  
days that do not contain the 48 values.

My question, how would I go about doing this?

Many thanks,


R-help at r-project.org mailing list
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