Dear R-list users,

I deal with semi-hourly data from automatic meteorological stations.

They have to pass a manual validation; suppose that status = "C" stands for 
correct and status = "D" for discarded.

Here a simple example with "Snow height" (HS):


mydf <- data.frame(data_POSIX=seq(as.POSIXct("2024-01-01 00:00:00", format = 
"%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), as.POSIXct("2024-01-02 23:30:00", format 
= "%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), by="30 min"))

mydf$hs <- round(runif(96, 0, 100))

mydf$status <- c(rep("C", 50), "S", rep("C", 45))


Evaluating the daily mean indipendently from the status is very easy:

aggregate(mydf$hs, by=list(format(mydf$data_POSIX, "%Y"), 
format(mydf$data_POSIX, "%m"), format(mydf$data_POSIX, "%d")), my.mean)


Things become more complicated when I need to export also the status: this 
should be "C" when all 48 data have status equal to "C", and status "D" when at 
least one value has status ="D".


I have no clue on how to do that in an efficient way.

Could some of you give me some clues on how to do that?


Thank you for your usual support

Stefano Sofia


         (oo)
--oOO--( )--OOo--------------------------------------
Stefano Sofia PhD
Civil Protection - Marche Region - Italy
Meteo Section
Snow Section
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona (AN)
Uff: +39 071 806 7743
E-mail: stefano.so...@regione.marche.it
---Oo---------oO----------------------------------------

________________________________

AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere 
informazioni confidenziali, pertanto � destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
� il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed 
urgenza, la risposta al presente messaggio di posta elettronica pu� essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

        [[alternative HTML version deleted]]

______________________________________________
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 https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to