Description Usage Arguments Details Value Note References Examples
This function compares two samples together (description)
1 | sub.test(sam1, sam2)
|
sam1, sam2 |
(arguments here) |
(details here; DIU)
result (return value here)
(notes here; DIU)
(references here: DIU)
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.