[R] table problems

Robin Hankin r.hankin at auckland.ac.nz
Wed Jun 12 04:08:16 CEST 2002


dear helplist,

my student has fifty trees, numbered one to fifty, and a vector
recording which tree a certain possum slept in on 12 nights.

R> c
 [1]  3 14 17 22 26 26 17 40 43 25 46 46
R> 

Thus it slept in tree #3 on Monday, then tree #14 on Tues, and so on.
I wish to test the null hypothesis that the animal chooses trees
randomly; try

R> table(c)
c
 3 14 17 22 25 26 40 43 46 
 1  1  2  1  1  2  1  1  2 
>

Thus it slept in tree #3 once, tree #14 once, tree #17 twice, etc.

Now on the null hypothesis the expected number of sleeps per tree is
12/50=0.24; so how do I carry out a chisquare test on the data,
including the trees that it never slept in?

chisq.test() doesn't "know" that there are actually fifty distinct
trees (most of which were never slept in) and not nine.

 > chisq.test(table(c))

	Chi-squared test for given probabilities

data:  table(c) 
X-squared = 1.5, df = 8, p-value = 0.9927

of course this isn't right because chisquared is > 25.8 due to the
animal sleeping in tree #17 and tree #46 twice (and of course, df
should be 49 because I have 50 trees).


help anyone?


-- 

Robin Hankin, Lecturer,
School of Geographical and Environmental Science
Private Bag 92019 Auckland
New Zealand

r.hankin at auckland.ac.nz
tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042

as of: Wed Jun 12 13:51:00 NZST 2002
This (linux) system up continuously for:  286 days, 20 hours, 33 minutes
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list