How to perform randomization test for categorical data and/or chi-square? I am very newbie in statistics and I my problem is as follows: 
I have a total set of 20,000 categorical observations (this is my whole dataset, say DATA1) which has a certain proportion of "yes" and "no" Ex: (id-1: yes, id-2: yes, id-3: no, id-4: no, ... id-20,000: yes). From the whole dataset, I have a particular subset of 3,000 observations of my interest (say DATA2) (Ex: id-1: yes, id-2: yes etc.). I would like to test if the proportion of "yes"/"no" in this particular sample is significant higher/lower than the whole dataset. The first approach I suppose to do is a chi-square test, is it right? If so, how the table should look like?
Another approach that I am considering (and I think it is the most correct), is to random sample from the whole dataset (DATA1) 3,000 observations for N = 1000 rounds and count for each round the number of "yes" and "no". I suppose that I cannot plot the distribution and get z-scores because the variables are categorical. So, I'm stuck in this point because I don't know how to compare the simulated data with the observed data (DATA2) and finish with the statistical significance or computed p-values. Anyone could help me out on this problem? The easiest way to me is a solution in R.
Thank you very much!     
 A: There is a fairly straightforward solution, without delving into your simulation idea.  It can be assessed as a modified $\chi^2$ Goodness of Fit question, where you treat DATA1 as a population, and DATA2 as your sample of interest.  The traditional null hypothesis for a GoF test is one of equal proportions (a test of 50% yeses versus 50% nos in your sample).  However, you can modify the test to check for differences from particular proportions of interest.  This is typically referred to as a test of "no differences from a known population".
So, what you could do is:


*

*Using the full dataset, find the proportion of yeses and nos.  This is your "population of interest".  This can be done using xtabs() on DATA1. For example, perhaps you find 75% yes rate, and 25% no.

*Use chisq.test() in the usual manner on your subset DATA2, but use the p argument to specify the probabilities that you obtained from the cross-tabulation.  Make sure to list them in order (e.g. if nos are coded in your dataset as 0s and yeses as 1s, then p should be entered as p = c(p0, p1); using the example it would be entered as p = c(.25, .75)).

