# Moving average with replicate X values

#### kmj

##### New Member
Hello,

I would like to calculate the moving average and confidence intervals of time series data. Alternatively, use a smoothing function (like loess). For some years I have upwards of 15 data points, for some years I have none.

I cannot figure out a way to calculate a moving average when every datapoint does not have a unique y value (it comes up with errors)

Ex.
> temp.zoo <- zoo(data$weight, data$year)
Warning message:
In zoo(data$weight, data$year) :
some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique

I've (hopefully) attached an example of what my data looks like.

Thank you very much for any tips/suggestions you may have!

Last edited: