sub.test: sub.test function

Description Usage Arguments Details Value Note References Examples

View source: R/WSeedCode2.R

Description

This function compares two samples together (description)

Usage

1
sub.test(sam1, sam2)

Arguments

sam1, sam2

(arguments here)

Details

(details here; DIU)

Value

result (return value here)

Note

(notes here; DIU)

References

(references here: DIU)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
fn<-file.choose(); ### C:\Users\wangy\Documents\Research Since 2013\Research 2016\Sub group trend comparison
dat<-read.csv(fn, header=TRUE);
attach(dat)

Lev.TN<-levels(TreatmentName);
Lev.Line<-levels(Line);
n<-dim(dat)[1]

idx<-(TreatmentName==Lev.TN[1])*(Line==Lev.Line[9])*(1:n)
boxplot(seedwt[idx]~Env[idx], main=paste(Lev.TN[1],'and',Lev.Line[9]),xlab="ENV levles",ylab='seedwt');
idx2<-(TreatmentName==Lev.TN[2])*(Line==Lev.Line[9])*(1:n)
boxplot(seedwt[idx2]~Env[idx2], main=paste(Lev.TN[2],'and',Lev.Line[9]),xlab="ENV levles",ylab='seedwt');

temp<-seedwt[idx];lab<-Env[idx]; uni.lab<-unique(lab)
sam.Ga.Mo352<-lapply(1:length(uni.lab), function(x) temp[lab==uni.lab[x]])
sam.Ga.Mo352 ### some are missing
avg.sam.Ga.Mo352<-unlist(lapply(sam.Ga.Mo352,mean,na.rm=TRUE));avg.sam.Ga.Mo352
sd.sam.Ga.Mo352<-unlist(lapply(sam.Ga.Mo352,sd,na.rm=TRUE));sd.sam.Ga.Mo352
size.sam.Ga.Mo352<-unlist(lapply(sam.Ga.Mo352,length));size.sam.Ga.Mo352
####
#### find the sd of second group;
temp2<-seedwt[idx2];lab2<-Env[idx2]; uni.lab2<-unique(lab2)
sam.nh.Mo352<-lapply(1:length(uni.lab2), function(x) temp2[lab2==uni.lab2[x]])
sam.nh.Mo352 ### some are missing and some are zero
avg.sam.nh.Mo352<-unlist(lapply(sam.nh.Mo352,mean,na.rm=TRUE));avg.sam.nh.Mo352
sd.sam.nh.Mo352<-unlist(lapply(sam.nh.Mo352,sd,na.rm=TRUE));sd.sam.nh.Mo352;
size.sam.nh.Mo352<-unlist(lapply(sam.nh.Mo352,length));size.sam.nh.Mo352
sub.test(sam.nh.Mo352,sam.Ga.Mo352)

miv5219/Stapleton_Lab documentation built on Nov. 4, 2019, 6:56 p.m.