Benjamin Telkamp - 7 months ago 51

R Question

I want to create a sampling distribution for a mean. I have a variable

`x`

`2`

`x <- rnorm(10000, 7.5, 1.5)`

draws = sample(x, size = 10 * 500, replace = TRUE)

draws = matrix(draws, 10)

drawmeans = apply(draws, 2, mean)

hist(drawmeans)

would be sincerely appreciated!

Answer

You could do this using `replicate`

if you wanted. One of lots of different ways. For data frame `df`

```
out = replicate(500, mean(sample(df$Scores,10)))
hist(out)
```

Source (Stackoverflow)