In R, prop.test can take a table of summary statistics (the cell counts from a cross tabulation) instead of all the data (see parameter x here):
x - a vector of counts of successes, a one-dimensional table with two entries, or a two-dimensional table (or matrix) with 2 columns, giving the counts of successes and failures, respectively.
Is there a way to give t.test (or some equivalent function) the summary statistics of mean, standard deviation, and group size for the two groups and have it perform the appropriate calculations?
There's already at least one package at CRAN which does the summary statistic version of the t-test, see the function tsum.test
in package BSDA.
This question on stats.SE includes a couple of sets of R code that should also suffice.
Notes:
The answers there don't seem to take advantage of the htest
class. I probably would have for consistency, though it's not such a big issue.
What I'd actually like to see is t.test
able to take a mix (both samples with observations or both with summaries, or one of each, which I don't think tsum.test
does either), and I'd like to see t.test properly handle the case of one sample with only a single observation (with var.equal=TRUE
only, naturally); as it stands all these additions are simple to do and not so infrequently required, it surprises me that the small number of additional lines are not simply inserted.
(Funny that that question was migrated the other direction from yours, I think they're pretty similar; in borderline cases, I guess there's going to be some questions that are migrated away that the people at the other end of the migration think should stay where they were. It may be that my question to you, and your answer, was actually what triggered the move in this case.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With