[R] Normality Test and T-Test

David Winsemius dwinsemius at comcast.net
Thu Jan 22 02:44:09 CET 2009


One of:

?by
?aggregate
?ave

Next time include the package name where these functions come from AND  
code that creates an example data situation and you will increase your  
probability of getting a more prompt and complete reply.

-- 
David Winsemius

On Jan 21, 2009, at 4:54 PM, Ferry wrote:

> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list