[R] bootstrap sample with R

John Sorkin jsorkin at grecc.umaryland.edu
Sun Dec 10 17:20:13 CET 2006


Ethan,
It is quite easy if you use the sample function with replace=TRUE:

> y<-rnorm(9,0,1)
> y
[1]  0.0625366 -0.1225751  0.1335859 -1.5930572  0.2493484 -0.1926270
-0.5615023
[8]  0.7537500  1.4977661
> sample(y,replace=TRUE)
[1]  1.4977661  0.1335859  0.0625366  0.2493484 -0.1225751  1.4977661 
0.7537500
[8]  0.2493484  0.0625366

John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
jsorkin at grecc.umaryland.edu

>>> "Ethan Johnsons" <ethan.johnsons at gmail.com> 12/10/06 2:27 AM >>>
How do you draw a bootstrap sample of size 9, with replacement, from
the random dataset I drew?   Is there a function for it in R?

9 random samples.

>rnorm(9, 0, 1)

[1]  1.2071538  0.3183367 -1.4237989 -0.4050909  0.9953866  0.9588178 
0.9180879
[8] -0.1509696 -1.2230688


thx

ej

______________________________________________
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.

Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}




More information about the R-help mailing list