Sampling with and without replacement

I seem unable to use "replace = F" when I want to sample without replacement. I would think that it comes down to "F is not a legitimate abbreviation for FALSE." except that
Dalgaard (p. 118) uses F for FALSE and it works
"pairwise.t.test(folate, ventilation, pool.sd = F)"

I am having trouble when I try to sample a vector without replacement.

The following code illustrates my problem.

>b <- c(1:8)

>sample(b)
[1] 7 8 3 5 1 6 2 4    # That works correctly--no replacement
(This would be my preferred form, but when I look at the code later it is helpful to know
 explicitly how I did the sampling.)

> sample(b, replace = T)
[1] 7 5 6 2 5 5 4 7    # That is also correct--replacement

> sample(b, replace = F)
[1] 1 7 3 7 3 4 6 5 # There are two 3s and two 7s, so there was replacement


>sample(b, replace = FALSE)
[1] 8 1 3 2 5 6 7 4    # That works just fine

>sample(b, replace = "F")
[1] 5 3 2 8 4 1 7 6     # quoting the F is fine.


If it is OK to replace TRUE with T, why can't I replace FALSE with F?


I have a similar problem if I write data <= read.table(file.choose(), header = F)

I'm using a Windows machine with version 2.8.0, but I'm sure that this is not a machine specific problem.
Thanks,
Dave Howell

--
David C. Howell
PO Box 770059
627 Meadowbrook Circle
Steamboat Springs, CO
80477

______________________________________________
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