Hi, I would like to ask how can I do the problem as follows by R. Thank you very much. Q: Create a list of twenty distinct first names, ten male and ten female, and store them into an array. Write a routine for selecting a simple random sample of five names and counts the number of male and female names in the sample when the sample is drawn : (a) with replacement (b) without replacement --------------------------------- Finding fabulous fares is fun. [[alternative HTML version deleted]]
Hi isnt it a homework? FYI see ?list ?vector ?data.frame ?sample ?lapply and some basic stuff like Introduction manual provided with your R instalation to see how some simple data manipulations can be done. Regards Petr Pikal petr.pikal at precheza.cz r-help-bounces at stat.math.ethz.ch napsal dne 05.04.2007 05:58:48:> Hi, > > I would like to ask how can I do the problem as follows by R. Thankyou very much.> > Q: Create a list of twenty distinct first names, ten male and tenfemale,> and store them into an array. Write a routine for selecting a simplerandom> sample of five names and counts the number of male and female names inthe> sample when the sample is drawn : > (a) with replacement > (b) without replacement > > > --------------------------------- > Finding fabulous fares is fun. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
?sample
nams  <-  c(rep("a",10), rep("b",10))
table(sample(nams, 5, replace = TRUE))
--- Chia-Yi Tseng <tseng_chiayi at yahoo.com> wrote:
> Hi,
>    
>   I would like to ask how can I do the problem as
> follows by R. Thank you very much.
>    
>   Q: Create a list of twenty distinct first names,
> ten male and ten female, and store them into an
> array. Write a routine for selecting a simple random
> sample of five names and counts the number of male
> and female names in the sample when the sample is
> drawn :
>   (a) with replacement
>   (b) without replacement
> 
>  
> ---------------------------------
> Finding fabulous fares is fun.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>