Do you have any ideas on how to maintain the columns with data that is not being used in calculating the mean in a circumstance where all row values are not constant? It is fine if SampleDate and day are lost. This may be a better representation of my data. The resulting data frame should contain 20 rows and 6 columns.
library(tidyverse)
library(lubridate)
monthlymean <- data.frame(
stringsAsFactors = FALSE,
AnalyteName = rep("chemx",11), rep("chemb",11)
SampleDate = c("2012-01-09","2012-08-14",
"2013-05-21","2014-09-09","2010-12-28","2013-03-28",
"2010-10-12","2010-03-14","2010-09-16","2012-01-21","2010-10-30", "2012-01-09","2012-08-14",
"2013-05-21","2014-09-09","2010-12-28","2013-03-28",
"2010-10-12","2010-03-14","2010-09-16","2012-01-21","2010-10-30"),
WBID = rep(12345,11), rep(54321,11)
ProjectName = rep("Water", 11), rep("Water1",11)
day = c(9L, 14L, 21L, 9L, 28L, 28L, 12L, 14L, 16L,21L, 30L, 9L, 14L, 21L, 9L, 28L, 28L, 12L, 14L, 16L,21L, 30L),
month = c(1L, 8L, 5L, 9L, 12L, 3L, 10L, 3L, 9L,1L,10L, 1L, 8L, 5L, 9L, 12L, 3L, 10L, 3L, 9L,1L,10L),
year=c(2012,2012,2013,2014,2010,2013,2010,2010,2012,2010,2010, 2012,2012,2013,2014,2010,2013,2010,2010,2012,2010,2010),
Result = c(0.23, 0.56, 9.56, 3.67, 2.67, 4.67, 2.56, 3.57, 2.45, 6.92, 2.56, 0.23, 0.56, 9.56, 3.67, 2.67, 4.67, 2.56, 3.57, 2.45, 6.92, 2.56)
)
[/quote]