Sunday date in mydates is 2018-05-06. I would like 1 day added so that 2018-05-06 becomes 2018-05-07 (Monday). That is, if a date falls on a Sunday add one day.
library(dplyr)
library(lubridate)
mydates <- as.Date(c('2018-05-01','2018-05-02','2018-05-05','2018-05-06'))
# find which are weekend dates
x = as.character(wday(mydates,TRUE))
if(x == 'Sun') { mydates + 1 }
# the Sunday date in mydates is 2018-05-06. I would like 1 day added so
that 2018-05-06 becomes 2018-05-07
Here's my error: Warning message: In if (x == "Sun") { : the condition has length > 1 and only the first element will be used