It is better programming practice to use FALSE for false and TRUE for true, and not F and T. This is because it is quite legal to do this:
T <- FALSE F <- TRUE or any other assignment. If you re-assign T or F (which are set to TRUE and FALSE at the beginning of a session), you run into the sort of problem that you have discovered. Also, there is the F and t distributions, and the t() function, so having variables called F and T may lead to further confusion. If you mean FALSE, say FALSE. If you mean TRUE, say TRUE. Cheers, Simon. On Sun, 2008-11-16 at 17:56 -0700, David C. Howell wrote: > 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 > -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. ______________________________________________ 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.