I've been learning R by going through "The R book" by Michael Crawley, and by reading and searching through the various excellent help files from R and around the internet. I was playing with what I thought was equivalent code to make sure I was understanding what I was asking R to do before I move into more difficult stuff, and came across something that I really don't understand and can't figure out.
I have a dataframe that consists of 2 factors (Nest and Egg), and one continuous variable (Incubation period). Incubation period is paired by Nest, and each Nest has an A and a B egg. I had the file sorted so within the dataframe, the Nest and Egg columns looked roughly like this:
and there was a number for Incubation for each row.
I ran a t.test on it in 2 ways like this:
with(ABeggs08nona,t.test(Incubation[Egg == "a"], Incubation[Egg == "b"],paired=T))
I'd also unstacked the data and ran a paired t.test on it that way to make sure I'd gotten it right; I got the same result from each, and it seemed to me that the syntax from the 2 codes above was equivalent.
In doing more searching on testing variances however, I've done the same thing for fligner.test:
with(ABeggs08nona,fligner.test(Incubation[Egg == "a"], Incubation[Egg == "b"]))
In this case, I got RADICALLY different results.
So, what am I missing? It looks to me that I've asked it, in the latter case, to pick out the rows that contain "a"s in the Egg column, and compare their Incubation periods to those in Egg's "b" column. Is that not what, in the first case, Incubation~Egg (Incubation as a function of Egg) is saying too?
Thanks for any tips you can provide!!