Если предположить, что ваш фрейм данных называется "Данные", я бы использовал xts package .С ними гораздо проще работать:
#Conversion of dates
Data$time <- as.POSIXct(Data$mdyhms,format="%b-%d-%Y %H:%M:%S")
#conversion to time series
library(xts)
TimeSeries <- xts(Data[,c("Ya","Yb")],Data[,"time"])
Тогда TimeSeries можно будет использовать впоследствии.Вы не можете использовать нормальный тс, потому что у вас нет регулярных временных рядов.Ни в коем случае вы не можете защитить, что интервалы времени между вашими наблюдениями равны.
РЕДАКТИРОВАТЬ:
В отношении ваших замечаний в комментариях вы можете попробовать следующее:
#Calculate the period they're into
#This is based on GMT and the fact that POSIXct gives the number of seconds
#passed since the origin. 5400 is 1/16 of 86400 seconds in a day
Data$mdyhms <- as.POSIXct(Data$mdyhms,format="%b-%d-%Y %H:%M:%S",tz="GMT")
Data$Period <- as.numeric(Data$mdyhms) %/% 5400 * 5400
#Make a new data frame with all periods in the range of the dataframe
Date <- as.numeric(trunc(Data$mdyhms,"day"))
nData <- data.frame(
Period = seq(min(Date),max(Date)+86399,by=5400)
)
# Merge both dataframes and take the mean of values within a dataframe
nData <- merge(Data[c('Ya','Yb','Period')],nData,by="Period",all=T)
nData <- ddply(nData,"Period",mean,na.rm=T)
#Make the time series and get rid of the NaN values
#These come from averaging vectors with only NA
TS <- ts(nData[c('Ya','Yb')],frequency=16)
TS[is.nan(TS)] <- NA