Hello Everyone,

I have a function **final** with arguments **x** and **y**. I would like to select y in such a way that months both **x** and **y** are equal.

For example:

In the first run, it would be x1+y1 and x2+y2.

Likewise, the 13th run will be x13+y1..... x14+y2.

I would be grateful if you can suggest ton the final code which tried as below.

Thanks

```
library(tidyverse)
dat <- data.frame("month"=01:12,
"mean_dat"=runif(12,1,15))
date1=seq(as.Date("2019/1/1"), as.Date("2019/12/31"), "days")
T_out=runif(length(date1),1,15)
output <- data.frame(date1,T_out)
output$mon=format(as.Date(output$date1, format="%Y-%m-%d"),"%m")
output$mon=as.numeric(output$mon)
head(output)
final<- function(x,y)x+y
(mapply (function(x, y) final(x, y),
x=output$T_out, y=ifelse(dat$month==output$mon, dat$mean_dat,0) ))
```