I have a dataframe called ants detailing multiple entries per site, looks like this:
Site Date Time Temp SpCond Salinity Depth Turbidity Chlorophyll
1 71 6/8/2010 14:50:35 14.32 49.88 32.66 0.397 0.0 1.3
2 71 6/8/2010 14:51:00 14.31 49.94 32.70 1.073 0.0 2.0
3 71 6/8/2010 14:51:16 14.32 49.95 32.71 1.034 -0.1 1.6
4 71 6/8/2010 14:51:29 14.31 49.96 32.71 1.030 -0.2 1.6
5 70 6/8/2010 14:53:55 14.30 50.04 32.77 1.002 -0.2 1.2
6 70 6/8/2010 14:54:09 14.30 50.03 32.77 0.993 -0.5 1.2
Sites have different numbers of entries, usually 3 but sometimes less or more. Where both date and site number match I would like to write a new dataframe with one entry per site detailing the average/mean readings for each parameter. I would like empty or “na” cells to be omitted from the calculation and subsequent dataframe.
I’m not sure if this is an apply function or a version of rowMeans maybe? Very stuck, any help much appreciated!
Here is a complete new answer with a full log also covering your new specification: