Repeat and Replicate function in R