[R] multiple t-tests
B Nichols
bjnicho2 at mail.usf.edu
Sun Aug 17 21:27:44 CEST 2008
This is probably a basic data manipulation issue and an easy answer, but
I can't seem to make it work. I am more used to working with data by
participant, not by answer.
I have survey data, one answer per line (18000+ lines and counting), and
each line includes variables for:
prepost (0 for pre, 1 for post)
question (the number of the question, from S1 to S85)
answer (a Likert range of 0-4)
I want to do t.tests (and Wilcox tests actually) on each question's pre
and post means, but I can't figure out a single statement that will do
this automatically, and I don't want to have to make 85 individual calls.
An individual call that seems to work with either t.test or wilcox.test
looks like:
t.test(subset(answer, question=="S04") ~ subset(prepost, question=="S04"))
It would also be great to have a table including the difference between
pre and posttest means. It seems these things should be doable, but I
just can't find the right statement with the data in this format.
Thanks,
Bryan
More information about the R-help
mailing list