In: Statistics and Probability
Using piping %>%, sample from the vector 1:10 1000 times with
replacement, calculate the resulting sampled vector’s mean, then
exponentiate that mean.
Please write in R Language. Thanks.
#load the package
library(dplyr)
#set the seed to reproduce the result
set.seed(123)
#sample of 1000 numbers from the elements
#of the vector 1:10 with replacement
sample(1:10, size = 1000, replace = TRUE) %>%
#compute the sample's mean
mean() %>%
#exponentiate the mean
exp()
Sample Output
P.S. - Please let me know if you have any query.