Help performing hypothesis tests automatically on a large data set in R I have a data frame in R with 100 variables (columns) and 100 observations (rows). Each row is a patient; the columns are different variables such as gender, height, body-mass index, etc. I know that I can easily compute summary estimates for all of my variables using the Hmisc library like so (note that I am using the veteran data set as an example).
library(Hmisc)
data(veteran)
describe(veteran)

First question
For this data set, there is a variable, trt, that can take two values. I would like to treat this as a categorical variable and stratify the describe function by this variable. That way I can know the summary information for all patients with a trt value of 1 and all patients with a trt value of 2.
Second question
I would like to quickly perform hypothesis tests to see if there is a significant difference between groups 1 and 2 for every other variable analyzed. For categorical variables, I'd like to automatically perform a Chi-sq test or Fisher's exact test. For continuous variables, I'd like to automatically perform a t test. And I want the code just to spit out some p values. Is there a way to do that?
Response to comment
My goal would be to use this code to easily compute what I would be putting into Table 1 of my manuscript, which will describe the baseline population characteristics. An example of such a table is here: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4281814/table/OFU040TB1/
My table would only have two columns. One for trt group 1, the other for trt group 2. And I would just report the means or median values, with a measure of dispersion like SD or IQR, then a p value for difference.
 A: For your first question, just do
describe(subset(veteran, trt == 1))
describe(subset(veteran, trt == 2))

or
describe(veteran[veteran$trt == 1,])
    describe(veteran[veteran$trt == 2,])

For your second question, seeing as this is a data-analysis site and not a programming site, I'm going to simply tell you don't do that. The purpose of this table in your manuscript, if I understand correctly, is just to give the reader a sense of what the sample was like. As @whuber mentioned, it is not wise to naively perform the simplest hypothesis test possible for every variable, for several reasons, among them that you are describing the sample in this table, not trying to make inferences about any populations. If subjects were randomly assigned to groups, the populations are the same and therefore they must have the same population characteristics. If they weren't, and you want to investigate questions like "Are smokers taller than non-smokers?", that is a question that deserves a careful analysis in the main text as part of the study per se, rather than an afterthought tucked into the demographics table, and you should be picking and choosing questions to ask instead of throwing everything against the wall and seeing what sticks—at least if you're going to use a null-hypothesis significance-testing approach.
A: Good answer from Kodiologist. Just wanted to give my two cents.
Answer 1:
I would use by() function as I did below. The by function applies a function to each level of a factor vector.
the first argument below is the data set (veterans), the second is the factor level (trt), and the third is the function (describe). 
attach(veteran)
by(veteran,trt,describe)

Answer 2:
You can code a very flexible function that will take a vector as input, determine whether it is categorical or not, and apply the relevant test while conditionally applying fisher exact in case you get a warning with chi sq test. 
Then you can use an apply family function to apply this flexible function to a list of variable names.
You can also not do this and use the functions chisq.test(), fisher.test(), or t.test() alone.
