I have a list of 152 dataframes named dfs (each with around 9 columns namely: Date, Station Name, Discharge, Course, Medium, Fine, Total, Q and S1)
I have duplicate dates and missing dates in each dataframe, I want to create a new list with the duplicate dates replaced with the mean of the data (a new list with the same dataframe elements retaining the Station Name which is a char}
for replacing missing dates with NA I use [which works fine]
dfs<-lapply(dfs, function(x)
x = pad(x))
but for duplicate dates I am struggling with this{i think a modification of aggregate function may help me}
dfs2<-transform(dfs, Date = as.Date(DATE, "%m/%d/%Y"))
dfs2<-aggregate(data ~ Date, dfs, function(x) mean(x, 1))
can anyone help me please?