Skip to content
Prev 378351 / 398502 Next

cumulative data monthly

Very succinct, Rui!

One warning to Diego.... automatic data recorders tend to use the local standard timezone year-round. R by default assumes that timestamps converted from character to POSIXct using the current timezone on your computer... which may not be in the same zone that the logger was in but even more commonly the computer follows daylight savings time. This leads to NAs showing up in your converted timestamps in spring and duplicated values in autumn as the data are misinterpreted. The easiest solution can be to use

Sys.setenv( TZ="GMT" )

though if you need the actual timezone you can use a zone name of the form "Etc/GMT+5" (5 hrs west of GMT).

Note that Rui's solution will only work correctly near the month transition if you pretend the data timezone is GMT or UTC. (Technically these are different so your mileage may vary but most implementations treat them as identical and I have not encountered any cases where they differ.)
On January 27, 2019 10:03:44 AM PST, Rui Barradas <ruipbarradas at sapo.pt> wrote: