sorry, i'm a bit of a bummer at copying and saving various pieces of
code
and I'm not very experienced with R
- I am trying to build a partnership with a local IT cooperative, but
this is a job that was not foreseen and it is not covered by budget, so
I am trying to solve it myself -
I do not want to ask in ml the ready turnkey solution, but some ideas
of what could be the set of packages and functions that could be right
for me, and if anyone has been faced with such a problem.
Thank you
Enrico Gabrielli
Il giorno mer, 09/06/2021 alle 14.47 -0700, Bert Gunter ha
scritto:> I have *not* followed this in any detail, but this line seems wrong:
>
> arvaia_catture_order <- arvaia_catture[order(arvaia_catture$tempo)]
> Perhaps it should be: arvaia_catture_order <-
> arvaia_catture[order(arvaia_catture$tempo), ] ## note the comma!
> If I am mistaken, just ignore and move on.
>
> Cheers,Bert
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming
> along and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip
)
>
>
> On Wed, Jun 9, 2021 at 2:41 PM Rui Barradas <ruipbarradas at sapo.pt>
> wrote:
> > Hello,
> >
> >
> >
> > I'm not getting your simple sum:
> >
> >
> >
> >
> >
> > arvaia_catture_order[, week := as.integer(format(tempo,
"%U"))]
> >
> > aggregate(catture ~ week, arvaia_catture_order, sum)
> >
> > # week catture
> >
> > #1 19 15
> >
> > #2 20 5
> >
> > #3 21 78
> >
> > #4 22 120
> >
> >
> >
> >
> >
> > Can you explain your result better?
> >
> >
> >
> > Hope this helps,
> >
> >
> >
> > Rui Barradas
> >
> >
> >
> > ?s 18:57 de 09/06/21, Enrico Gabrielli escreveu:
> >
> > > 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,4375integrand_2 <- function(x) {0.62 *
(1/x)}
> >
> >
> >
> > integrate(integrand, lower = , upper = 5)
> >
> >
> >
> > > 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
> >
> > >
> >
> >
> >
> > ______________________________________________
> >
> > R-help at 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.
> >
>
>
[[alternative HTML version deleted]]