Hello. I have a dataframe that has a date column. The intervals between dates vary. I want to convert this to a ts object. I was able to convert it to an xts object but the package I want to analyse this data with (called 'changepoint') does not seem to want to deal with xts. In the example they give they use the following:
data(discoveries) dis.pelt=cpt.meanvar(discoveries,test.stat='Poisson',method='PELT') plot(dis.pelt,cpt.width=3) cpts.ts(dis.pelt) and if I check: str(discoveries) Time-Series [1:100] from 1860 to 1959: 5 3 0 2 0 3 2 3 6 1 ... If I try with my data str(testTSRad) An 'xts' object on 2011-07-16 07:08:02/2013-09-20 01:25:48 containing: Data: num [1:501, 1] 76 77 79 86 79 79 85 86 89 88 ... Indexed by objects of class: [POSIXct,POSIXt] TZ: xts Attributes: NULL where I used this: testTSRad=xts(radSampPerRegion[[2]][ ,2],order.by=as.POSIXct(radSampPerRegion[[2]][ ,1])) I get this: testt=cpt.mean(testTSRad) Error in single.mean.norm(data, penalty, pen.value, class, param.estimates) : Data must have atleast 2 observations to fit a changepoint model. My data is below. Is there a way to convert it to ts? head(testTSRad) [,1] 2011-07-16 07:08:02 76 2011-07-16 07:08:06 77 2011-07-16 07:08:12 79 2011-07-16 07:08:16 86 2011-07-16 07:08:22 79 2011-07-16 07:08:26 79 [[alternative HTML version deleted]] ______________________________________________ R-help@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.