# Resample dataframe by random subset of years

I have a dataset of 59 years worth of daily rainfall data.

I'd like to resample the data by 6 randomly selected years 1,000 times, using the entire year of data for each of the 6 years (so 2190 observations in total).

Currently, the line of code I'm using only selects a random set of observations but not necessarily within the same year.

duration6 <- duration[sample(1:nrow(duration\$WrYear), 2190, replace=TRUE),]

Any help in the right direction would be appreciated!

• Thanks

duration6 <- duration[duration$$WrYear %in% sample(unique(duration$$WrYear), 6, replace=TRUE),]