[R] Normality Test and T-Test
Ferry
fmi.mlist at gmail.com
Wed Jan 21 22:54:58 CET 2009
Hello R Users,
Suppose I have data with the structure below:
Group_Name Pre_Test Post_Test
Grp_A xxx xxx
Grp_A xxx xxx
Grp_A xxx xxx
...
Grp_B xxx xxx
Grp_B xxx xxx
...
Grp_Z xxx xxx
Grp_Z xxx xxx
Grp_Z xxx xxx
Number of observations of each group are varies.
I want to conduct Normality test (ad.test for Anderson Darling or
pearson.test for Pearson) for each group by their pre and post values.
Later, I want to do a t-test.
Is there a better way to do normality test for each group without the
need of loop? At this moment, the only thing I can think of is
separating each group (and their pre / post test values) by creating
bunch of smaller set, and do the test by way of looping.
For example:
group_name <- unique(mydata.frame$group_name) ## or something similar
for (each_group in group_name) {
smaller_set <- subset(mydata.frame, group_name == each_group)
each_pretest <- ad.test(smaller_set$pre_test)
each_posttest <- ad.test(smaller_set$post_test)
print(paste(each_group, "pre_test p-value:",
each_pretest$p.value, sep = ""))
print(paste(each_group, "post_test p-value:",
each_pretest$p.value, sep = ""))
}
and the same thing with t-test.
Any idea is appreciated.
Thank you.
Ferry
More information about the R-help
mailing list