Re: [R] Listing tables together from random samples from a generated population?

2011-11-10 Thread Dennis Murphy
Hi: There are two ways you could go about this: lists or arrays. It's pretty easy to generate an array, a little more work to get the list. I'm assuming the objective is to extract a chi-square statistic from each table, so I'll show a couple of ways to do that, too. library('plyr') ## Start wit

Re: [R] Listing tables together from random samples from a generated population?

2011-11-10 Thread Jean V Adams
You could try something like this: tables <- lapply(seq(100), function(i) table(.y[sample(nrow(.y), 200), ])) Then you could conduct the chi-squared tests chisqs <- lapply(tables, chisq.test) and save the values .z <- sapply(chisqs, "[[", "statistic") Jean --- Simon Kis

[R] Listing tables together from random samples from a generated population?

2011-11-10 Thread Simon Kiss
. HI there, I'd like to show demonstrate how the chi-squared distribution works, so I've come up with a sample data frame of two categorical variables y<-data.frame(gender=sample(c('Male', 'Female'), size=10, replace=TRUE, c(0.5, 0.5)), tea=sample(c('Yes', 'No'), size=10, replace=TRUE, c(