Hello I just registered on the list. I am an agricultural technician and I am collaborating on a research project on agroforestry and Brown Marmorated Stink Bug (Halyomorpha halys, abbreviated BMSB).
Through kobotoolbox we are collecting data of catches in traps on farms. Farms register inconsistently. I am trying to use packages for irregular time series. Here an exemple the data: # variable monitoring time as register an import from kobotoolbox tempo <- as.POSIXct(c("2021-05-29 17:00:00 UTC","2021-06-05 10:52:00 UTC","2021-06-01 17:00:00 UTC","2021-05-16 08:34:00 UTC","2021-06-05 17:00:00 UTC","2021-05-29 05:30:00 UTC","2021-05-23 06:30:00 UTC","2021-05-20 13:00:00 UTC","2021-05-15 12:09:00 UTC")) # variable capture of BMSB catture <- c(25,92,23,2,5,30,23,3,15) # resulting table library(data.table) arvaia_catture <- data.table(tempo,catture) # order by time arvaia_catture_order <- arvaia_catture[order(arvaia_catture$tempo)] the catches refer to an interval, which goes from the previous monitoring up to the one recorded on the date our aim is to calculate the weekly catch also when a farmer, for example, enters the data on Thursday and Tuesday of the following week, on Tuesday in the trap he will find individuals who were also captured on Friday and Saturday, which formally are to be considered in the previous week. With the data of the example the results (with a spreadsheet) is two possibile solution week simple SUM week right SUM week 19 17 19,44027778 20 26 52,91388889 21 55 46,4375 22 120 99,20833333 The right SUM week is right! I have made several attempts with lubridate, padr, xts but the last one seems interesting to me with DTSg doing x_periodic <- alter(x,na.status = 'explicit',from="2021-05-15 12:00:00",by="min") colapply(x_periodic, fun = interpolateLinear) I managed to create a vector with all interpolated hours but with DTSg I still can't aggregate by week Has anyone on the list ever faced such a problem? Thank you -- Perito agrario Enrico Gabrielli Tessera n. 633 Collegio Periti agrari prov. Di Modena Biblioteca agricoltura: https://www.zotero.org/groups/aplomb/ https://it.linkedin.com/pub/enrico-gabrielli/9a/186/159 https://enricogabrielli76.wordpress.com/ https://www.inaturalist.org/observations/bonushenricus skype: enricogabrielli (enricogabrielli76.per...@gmail.com) ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.