Hello,
I forgot in my previous answer, sorry for the duplicated mails.
The function in my previous mail has a na.rm argument, defaulting to
FALSE, pass na.rm = TRUE to remove the NA's.
agg <- aggregate(cfs ~ date, df1, fun, na.rm = TRUE)
Or simply change the default. I prefer to set na.rm = FALSE because
that's what R's functions do. And I will only be used to one default,
with base R functions or my own code.
Hope this helps,
Rui Barradas
?s 17:52 de 29/08/21, Rich Shepard escreveu:> On Sun, 29 Aug 2021, Jeff Newmiller wrote:
>
>> The general idea is to create a "grouping" column with
repeated values
>> for
>> each day, and then to use aggregate to compute your combined results.
The
>> dplyr package's group_by/summarise functions can also do this, and
there
>> are also proponents of the data.table package which is high performance
>> but tends to depend on altering data in-place unlike most other R data
>> handling functions.
>>
>> Also pay attention to missing data... if you have any then you will
need
>> to consider whether you want the strictness of na.rm=FALSE or
>> permissiveness of na.rm=TRUE for your aggregation functions.
>
> Jeff,
>
> Thank you. Yes, there are missing data as sometimes the equipment fails, or
> there's some other reason why some samples are missing.
>
> Grouping on each day is just what I need. I'll re-learn dplyr and take
a
> look at data.table.
>
> Regards,
>
> Rich
>
> ______________________________________________
> 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.