Comment by apwheele
3 hours ago
I mean, for the main simulation I would do it like this:
set.seed(10)
n <- 10000; samp_size <- 60
df <- data.frame(
uniform = runif(n, min = -20, max = 20),
normal = rnorm(n, mean = 0, sd = 4),
binomial = rbinom(n, size = 1, prob = .5),
beta = rbeta(n, shape1 = .9, shape2 = .5),
exponential = rexp(n, .4),
chisquare = rchisq(n, df = 2)
)
sf <- function(df,samp_size){
sdf <- df[sample.int(nrow(df),samp_size),]
colMeans(sdf)
}
sim <- t(replicate(20000,sf(df,samp_size)))
I am old, so I do not like tidyverse either -- I can concede it is of personal preference though. (Personally do not agree with the lattice vs ggplot comment for example.)
No comments yet
Contribute on Hacker News ↗