Mike

I split the answer into three parts:

A. Random sampling
To random select 500 from 5000, you can use:> data5000 = rnorm(5000,200,10)
# make some data
> s = sample(data5000,500)
> head(s)
[1] 201.7548 167.5157 106.1064 194.6629 165.9758 187.1152

B. Repeated Random Sampling
Its not clear with what you mean by creating 500 sample means, but if you
meant
(1) draw 500 samples from 5000 and
(2) repeat step (1) 500 times, calculating the mean every time then you can
do it like so
> means500 <- replicate(500,mean(sample(data5000,500)))
> head(means500)
[1] 200.9172 197.4371 199.9544 202.2562 197.8169 199.3558

C. Draw the histogram
Drawing a histogram of means500 is achieved using the hist function
> hist(means500)

HTH
Schalk Heunis


On Sat, Sep 19, 2009 at 11:24 PM, MikeH78 <holli...@crimson.ua.edu> wrote:

>
> I was wondering if anyone could help me with a problem.  I need to randomly
> select, say 500 subjects from the 5000 cases I have and then need to run a
> test to create 500 sample means and graph the means in a histogram.  Does
> anyone know how to do this.  I'm not that familiar with R so please be
> patient with me.
>
> Thanks a lot!
>
> Mike Hollingsworth
> --
> View this message in context:
> http://www.nabble.com/random-selection-from-dataset-and-creating-and-graphing-multiple-means-tp25525555p25525555.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to