removing duplicate dates with the mean value in a list of dataframes

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?

Can you repost minimal reproducible codes along with data for the forum users to help you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.