Error in data.frame()

Hello, I am trying to create sample size from the dataset that I have got, the dataset that I am using is the following;, but I have removed the index and the height categories as they are not needed.

I am trying to create a random sample size of 10 and 5 and the sample should be ran 1000 times for each sample size, I am then trying to get the sample mean for each of those sample sizes but I am very confused on how to do it as this is my first week learning R Studio

Any help would be appreciated

If I'm understanding you correctly it sounds like you want to take a sample of size 5 and then take the mean, so something like this:

mean(sample(Weight$Weight, size = 5)

But then you want to do that 1000 times. So then you could use the replicate() function:

rep.out <- replicate(n = 1000, mean(sample(Weight$Weight, size = 5)))

For the sample size of 10, replace size = 5 with size = 10.

Thank you, this works, however how would I be able to plot the rep.out for both sample sizes on a density chart to show the difference?

Would be appreciated

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.