I have a function that adds a random integer to a date:

```
rand_to_date = function(date){
newdate = as.Date(date) + sample(1:30, 1)
return(as.Date(newdate))
}

```

which works fine. However, if I attempt to use sapply to apply this function to a vector of dates, e.g.

```
test_dates = c('2001-01-01', '2002-02-02', '2003-03-03', '2004-04-04')

```

sapply will not return a vector of output in date format:

```
 sapply(test_dates,rand_to_date)
 2001-01-01 2002-02-02 2003-03-03 2004-04-04 
 11329      11748      12115      12513

```

In contrast, lapply will return a list of dates. However, applying unlist to this output once again gives me a vector of numbers rather than dates. Nor does

```
sapply(sapply(test,rand_to_date), as.Date)

```

work. What's the simplest way for me to give a vector of these randomized dates as output?