[R] question

arun smartpink111 at yahoo.com
Sat May 11 05:15:22 CEST 2013


Hi,
Try this:
Specc1<- Specc[1:40,]
test(Specc,FacGroup)
#[1] "wilcox.test" "chisq.test" 
dim(Specc)
#[1] 31544    51

WTpval<- sapply(seq_len(nrow(Specc)),function(i) {indC<-grep("^c",names(Specc));indT<- grep("^t",names(Specc));wilcox.test(unlist(Specc[i,indC]),unlist(Specc[i,indT]))$p.value})
 length(WTpval)
#[1] 31544
 head(WTpval)
#[1] 4.799266e-06 5.552020e-04 8.830487e-02 1.619240e-01 1.668777e-03
#[6] 3.447155e-03

 ChiSqpval<- sapply(seq_len(nrow(Specc)),function(i) {indC<- grep("^c",names(Specc));indT<- grep("^t",names(Specc));chisq.test(c(sum(Specc[i,indC]),sum(Specc[i,indT])))$p.value})
length(ChiSqpval)
#[1] 31544
 head(ChiSqpval)
#[1] 0.006069972 0.003892417 0.102470435 0.239316541 0.002699796 0.004677735
A.K.









________________________________
From: Vera Costa <veracosta.rt at gmail.com>
To: arun <smartpink111 at yahoo.com> 
Sent: Thursday, May 2, 2013 11:20 AM
Subject: Re: question



Ok, forget this function, it isn't work. 
The code is working just:

GetFileList <- function(directory,number){
 # input: directory="l" directory to extract files from, number="c" experiment
 # output: "l" list files
 # aim: based on a directory extract filenames for analysis
 setwd(directory)
 filelist1<-dir()[file.info(dir())$isdir]
    direct<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), full.names = FALSE, recursive = TRUE)
 direct<-lapply(direct,function(x) paste(directory,"/",x,sep=""))
    lista<-unlist(direct)
 output<- list(filelist1,lista)
 return(output)
    }

ReadDir<-function(FacGroup){
 # input: 
 # output: 
 # aim: based on a directory extract filenames for analysis
 list.new<-lista[FacGroup!=0]
 read.list<-lapply(list.new, function(x) read.table(x,header=TRUE, sep = "\t"))
 names(read.list)<-file.list.names[FacGroup!=0]
 return (read.list)
} 
Spec <- function(lista,FDR_k) {
  # input: lista="l" list of files, FDR_k="k" cut off value for false discovery rate 
  # output: "df" with Pep, Mod, z, counts.... 
  # aim: to generate a merged matrix of counts based on a file list with individual peptide counts
  list.new<-lapply(lista,function(x) within(x,{spec<- as.character(spec)}))
  split.list<-split(list.new,names(lista))
  #Data needed with FDR<FDR_k
  seq.mod.z<-lapply(seq_along(split.list),function(i) lapply(split.list[[i]],function(x) x[x[["FDR"]]<FDR_k,c("Seq","Mod","z","spec")]))
  names(seq.mod.z)<- names(split.list)
  #insert colunm with the name of the folder
  folder.name<-lapply(seq.mod.z,function(x) lapply(names(x),function(i) do.call(rbind,lapply(x[i],function(x) cbind(folder_name=i,x)))))
  #merge data with the same Seq, Mod and z
  library(plyr)
  library(data.table)
  # "dt, df, l"
  merge.data<- lapply(folder.name,function(x) lapply(x,function(x1) {x1<-data.table(x1); x1[,spec:=paste(spec,collapse=","),by=c("Seq","Mod","z")]}))
  #colunm with number of spec
  count.spec<-lapply(merge.data,function(x) lapply(x,function(x1) {x1$counts<-sapply(x1$spec, function(x2) length(gsub("\\s", "", unlist(strsplit(x2, ",")))));x3<-as.data.frame(x1);names(x3)[6]<- as.character(unique(x3$folder_name));x3[,-c(1,5)]}))
  print(count.spec)
 count.specUnique<-lapply(count.spec,function(x) lapply(x,unique))
  #count spec by group (2-columns)
  spec.group<-lapply(count.specUnique,function(x) Reduce(function(...) merge(...,by=c("Seq","Mod","z"),all=TRUE),x))
   #spec.group1<-spec.group[lapply(spec.group,length)!=0]
  #data frame with count of spec
  res<- Reduce(function(...) merge(...,by=c("Seq","Mod","z"),all=TRUE),spec.group)
  res[is.na(res)] <- 0
 res<- as.data.frame(res,stringsAsFactors=FALSE)
 res
 }
test<-function(quantity, FacGroup,a_t=0.5){
 groups<-quantity[,4:ncol(quantity)]
 print(groups)
 #testing normality of each row
 normality<-apply(groups,1,function(x) if(length(unique(x))==1) 0 else shapiro.test(x)$p.value)
 print(normality)
 #if more than 50% is normal, consider all normal
 length.normality<-length(normality[normality>0.05])
 length.groups<-nrow(groups)
 a<-length(unique(FacGroup[FacGroup!=0]))
 print(a)
#condition to see the best test
if(a<=2){
 if(length.normality>a_t*(length.groups)){
  "t-test"} else {
  c("wilcox.test", "chisq.test")
  }
 } else{ 
 if(length.normality>0.5*(length.groups)){
 "ANOVA"} else {
 c("kruskal.test","chisq.test")
 }
 }
}
directory<-"C:/Users/Vera Costa/Desktop/dados1"
 file.list.names<-GetFileList(directory,23) [[1]]
 lista<-GetFileList(directory,23) [[2]]
#FacGroup<-c(0,1,0,2,2,0,3)
FacGroup<-c(0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)
#FacGroup<-c(0,1,1,1,0,2,2,2)
ListFacGroup<-ReadDir(FacGroup)
#spec(file.list.names,c(0,1,1,1,0,2,2,2),0.05) 
#Specc<-Spec(ListFacGroup,0.05) 
Specc<-head(Spec(ListFacGroup,0.05),30)
Specc
test1<-test(Specc, FacGroup)
test1


Now, I need a new function that apply the test of this function. In this case, wilcox.test and chisq.test.

Thank you









2013/5/2 arun <smartpink111 at yahoo.com>

Hi,
>Please check your test() function:
>
>test<-function(quantity, FacGroup,a_t=0.5){
>
> groups<-quantity[,4:ncol(quantity)]
> #print(groups)
> #testing normality of each row
>
> normality<-apply(groups,1,function(x) if(length(unique(x))==1) 0 else shapiro.test(x)$p.value)
>
> #print(normality)
> #if more than 50% is normal, consider all normal
>
> length.normality<-length(normality[normality>0.05])
> length.groups<-nrow(groups)
> a<-length(unique(FacGroup[FacGroup!=0]))
>
> #print(a)
>#condition to see the best test
>if(a<=2){
>if(length.normality>a_t*(length.groups)){
> "t-test"} else {
>
> c("wilcox.test", "chisq.test")
> }
>} else{
>if(length.normality>0.5*(length.groups)){
> "ANOVA"} else {
>
> c("kruskal.test","chisq.test")
> }
> }
>}
>testFunction<-function(data,test){
>test1<-apply(data,1,test[1])
>print(test1)
>}
> testFunction(Specc,test)
>Error in test[1] : object of type 'closure' is not subsettable
>
>
>
>
>
>----- Original Message -----
>From: arun <smartpink111 at yahoo.com>
>To: Vera Costa <veracosta.rt at gmail.com>
>Cc:
>
>Sent: Wednesday, May 1, 2013 10:43 PM
>Subject: Re: question
>
>
>
>Hi,
>I was reading your data.  YOu mentiioned that the test() function is okay, right?  But, then why did you comment out the test() function?  Also, based on the results of test(), if you have to do chi.sq test() or kruskal test
>head(Specc)
>                        Seq                 Mod z c10 c11 c12 c13 c14 c15 c16
>1          aAAAAAAAAAGAAGGR          1-n_acPro/ 2   0   0   0   0   1   1   1
>2     aAAAAAAAGAAGGRGSGPGRR          1-n_acPro/ 2   1   1   1   1   0   0   0
>3            aAAAAAGAGPEMVR          1-n_acPro/ 2   0   0   0   0   2   2   2
>4           aAAAAATAAAAASIR          1-n_acPro/ 2   1   1   1   1   0   0   0
>5 aAAAAEQQQFYLLLGNLLSPDNVVR 1-<_Carbamoylation/ 2   0   0   0   0   0   0   0
>6 aAAAAEQQQFYLLLGNLLSPDNVVR 1-<_Carbamoylation/ 3   0   0   0   0   0   0   0
>  c17 c18 c19 c2 c20 c21 c22 c23 c24 c3 c4 c5 c6 c7 c8 c9 t10 t11 t12 t13 t14
>1   1   1   0  1   1   0   0   0   1  0  1  0  0  0  0  0   1   1   1   1   1
>2   0   0   1  0   0   0   0   0   0  0  1  1  1  1  1  1   0   0   0   0   0
>3   2   2   0  2   2   1   1   1   2  1  1  0  0  0  0  0   1   1   2   2   2
>4   0   0   1  0   0   0   0   0   0  0  0  1  1  1  1  1   1   1   0   0   0
>5   0   0   0  0   0   0   0   0   0  0  0  0  0  0  0  0   0   0   1   1   1
>6   0   0   0  0   0   0   0   0   0  0  0  0  0  0  0  0   0   0   1   1   1
>  t15 t16 t17 t18 t19 t2 t20 t21 t22 t23 t24 t25 t26 t3 t4 t5 t6 t7 t8 t9
>1   1   1   1   1   1  1   1   1   1   1   1   1   1  1  1  1  1  1  1  1
>2   0   0   0   0   0  0   0   0   0   0   0   0   0  0  1  0  0  0  0  0
>3   2   2   2   2   1  1   1   1   1   1   1   1   2  1  1  1  1  1  1  1
>4   0   0   0   0   1  1   1   1   1   1   1   1   0  1  0  1  1  1  1  1
>5   1   1   1   1   0  0   0   0   0   0   0   0   1  0  1  0  0  0  0  0
>6   1   1   1   1   0  0   0   0   0   0   0   0   1  0  0  0  0  0  0  0
>
>
>Here, if I am going to do a chisq.test() based on rows, I would need to do it by groups i.e. "c" vs. "t".  In the process, I have to sum the all the "c" counts, and the "t" counts per row.  Is that what you wanted.
>
>
>_____________________________
>From: Vera Costa <veracosta.rt at gmail.com>
>To: arun <smartpink111 at yahoo.com>
>Sent: Wednesday, May 1, 2013 10:07 AM
>Subject: Re: question
>
>
>
>Hi again.
>
>I have this "simulate" data. With this you could do some help?
>
>The code (with different FacGroup) is :
>
>GetFileList <- function(directory,number){
> # input: directory="l" directory to extract files from, number="c" experiment
> # output: "l" list files
> # aim: based on a directory extract filenames for analysis
> setwd(directory)
> filelist1<-dir()[file.info(dir())$isdir]
>    direct<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), full.names = FALSE, recursive = TRUE)
> direct<-lapply(direct,function(x) paste(directory,"/",x,sep=""))
>    lista<-unlist(direct)
> output<- list(filelist1,lista)
> return(output)
>    }
>
>ReadDir<-function(FacGroup){
> # input:
> # output:
> # aim: based on a directory extract filenames for analysis
> list.new<-lista[FacGroup!=0]
> read.list<-lapply(list.new, function(x) read.table(x,header=TRUE, sep = "\t"))
> names(read.list)<-file.list.names[FacGroup!=0]
> return (read.list)
>}
>Spec <- function(lista,FDR_k) {
>  # input: lista="l" list of files, FDR_k="k" cut off value for false discovery rate
>  # output: "df" with Pep, Mod, z, counts....
>  # aim: to generate a merged matrix of counts based on a file list with individual peptide counts
>  list.new<-lapply(lista,function(x) within(x,{spec<- as.character(spec)}))
>  split.list<-split(list.new,names(lista))
>  #Data needed with FDR<FDR_k
>  seq.mod.z<-lapply(seq_along(split.list),function(i) lapply(split.list[[i]],function(x) x[x[["FDR"]]<FDR_k,c("Seq","Mod","z","spec")]))
>  names(seq.mod.z)<- names(split.list)
>  #insert colunm with the name of the folder
>  folder.name<-lapply(seq.mod.z,function(x) lapply(names(x),function(i) do.call(rbind,lapply(x[i],function(x) cbind(folder_name=i,x)))))
>  #merge data with the same Seq, Mod and z
>  library(plyr)
>  library(data.table)
>  # "dt, df, l"
>  merge.data<- lapply(folder.name,function(x) lapply(x,function(x1) {x1<-data.table(x1); x1[,spec:=paste(spec,collapse=","),by=c("Seq","Mod","z")]}))
>  #colunm with number of spec
>  count.spec<-lapply(merge.data,function(x) lapply(x,function(x1) {x1$counts<-sapply(x1$spec, function(x2) length(gsub("\\s", "", unlist(strsplit(x2, ",")))));x3<-as.data.frame(x1);names(x3)[6]<- as.character(unique(x3$folder_name));x3[,-c(1,5)]}))
>  print(count.spec)
> count.specUnique<-lapply(count.spec,function(x) lapply(x,unique))
>  #count spec by group (2-columns)
>  spec.group<-lapply(count.specUnique,function(x) Reduce(function(...) merge(...,by=c("Seq","Mod","z"),all=TRUE),x))
>   #spec.group1<-spec.group[lapply(spec.group,length)!=0]
>  #data frame with count of spec
>  res<- Reduce(function(...) merge(...,by=c("Seq","Mod","z"),all=TRUE),spec.group)
>  res[is.na(res)] <- 0
> res<- as.data.frame(res,stringsAsFactors=FALSE)
> res
> }
>#test<-function(quantity, FacGroup,a_t=0.5){
> #groups<-quantity[,4:ncol(quantity)]
> #print(groups)
> #testing normality of each row
> #normality<-apply(groups,1,function(x) if(length(unique(x))==1) 0 else shapiro.test(x)$p.value)
> #print(normality)
> #if more than 50% is normal, consider all normal
> #length.normality<-length(normality[normality>0.05])
> #length.groups<-nrow(groups)
> #a<-length(unique(FacGroup[FacGroup!=0]))
> #print(a)
>#condition to see the best test
>#if(a<=2){
> #if(length.normality>a_t*(length.groups)){
> # "t-test"} else {
> # c("wilcox.test", "chisq.test")
> # }
> #} else{
> #if(length.normality>0.5*(length.groups)){
> #"ANOVA"} else {
> #c("kruskal.test","chisq.test")
> #}
> #}
>#}
>#testFunction<-function(data,test){
>#test1<-apply(data,1,test[1])
>#print(test1)
>#}
>directory<-"C:/Users/Vera Costa/Desktop/dados1"
> file.list.names<-GetFileList(directory,23) [[1]]
> lista<-GetFileList(directory,23) [[2]]
>#FacGroup<-c(0,1,0,2,2,0,3)
>FacGroup<-c(0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)
>#FacGroup<-c(0,1,1,1,0,2,2,2)
>ListFacGroup<-ReadDir(FacGroup)
>#spec(file.list.names,c(0,1,1,1,0,2,2,2),0.05)
>#Specc<-Spec(ListFacGroup,0.05)
>Specc<-head(Spec(ListFacGroup,0.05),30)
>Specc
>
>
>
>
>and the data is in attach.
>
>If you can, thank you, if not, no problem.
>
>Thank you
>
>
>
>2013/4/30 Vera Costa <veracosta.rt at gmail.com>
>
>Because I just need to construct the code, maybe to apply to other data. But now,they just give me this. If they will give me data with 100 (for example), I just run the code. This data only gives the idea...
>>But I understand your position.
>>Thank you.
>>
>>No dia 30 de Abr de 2013 19:16, "arun" <smartpink111 at yahoo.com> escreveu:
>>
>>Sorry, as I mentioned I can't give you false information.  What do you mean by "you need to do that?"  Is it okay for you and your boss to give report results that are  not correct? 
>>>
>>>
>>>
>>>________________________________
>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>To: arun <smartpink111 at yahoo.com>
>>>Sent: Tuesday, April 30, 2013 2:11 PM
>>>Subject: Re: question
>>>
>>>
>>>
>>>But I need to do that. Now I have only this,but in some cases I could have more, i need to contruct the code like if I have another data.
>>>But if you can't, i will try.
>>>Thank you
>>>No dia 30 de Abr de 2013 19:04, "arun" <smartpink111 at yahoo.com> escreveu:
>>>
>>>To your question:
>>>>There is a response:
>>>>
>>>>"
>>>>There are no tests that have reasonable size and power properties for such small samples! Please correct me if I'm wrong."
>>>>
>>>>I also feel the same way.  I think if there is no power, then this test looks meaningless.  Sorry!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>________________________________
>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>To: arun <smartpink111 at yahoo.com>
>>>>Sent: Tuesday, April 30, 2013 1:58 PM
>>>>Subject: Re: question
>>>>
>>>>
>>>>
>>>>Oh, you really want that I put a post to ask this...:-)
>>>>I have this
>>>>http://www.talkstats.com/showthread.php/42929-tests-for-normal-data/page2
>>>>
>>>>Someone talks about Anderson-darling, but I never listen this...
>>>>
>>>>But the power is bad, but if don't do, can I do anything with this data?
>>>>
>>>>Thank you
>>>>
>>>>
>>>>
>>>>2013/4/30 arun <smartpink111 at yahoo.com>
>>>>
>>>>
>>>>>
>>>>>
>>>>>where is the link?
>>>>>
>>>>>
>>>>>
>>>>>________________________________
>>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>Sent: Tuesday, April 30, 2013 1:48 PM
>>>>>
>>>>>Subject: Re: question
>>>>>
>>>>>
>>>>>
>>>>>I already asked. All people put the problem about the quantity of data, because the test don't have good power. But, it's possible to apply (but with a small confidance).
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>2013/4/30 arun <smartpink111 at yahoo.com>
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>>HI,
>>>>>>I told you to ask the question at stackexchange.com.  If you can show the link where somebody responded to it in a positive manner, I can proceed.   Otherwise, I don't feel right to give advice on something which I don't feel right.
>>>>>>
>>>>>>
>>>>>>________________________________
>>>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>Sent: Tuesday, April 30, 2013 1:08 PM
>>>>>>
>>>>>>Subject: Re: question
>>>>>>
>>>>>>
>>>>>>
>>>>>>Hi. I have already asked in some places and people about the problem that you asked me.
>>>>>>It's true that the power of the tests isn't good. But I can to apply this. In the end I will do something about the power of the tests, but now I can do that.
>>>>>>
>>>>>>If you could do (or not) some help..thank you. I'm really learning about this.
>>>>>>
>>>>>>
>>>>>>
>>>>>>2013/4/27 arun <smartpink111 at yahoo.com>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>Yes, I understand, but applying different normality tests  on a very small dataset doesn't look good and the discussion on that link also ascertains that fact.  In some cases, we don't do these normality tests.  Especially in anova, there is an underlying assumption that the data is normal.   Anway, I am sorry I can't help you with this as I don't believe in the approach.  As I mentioned before, you can post it at R-help whether you can apply these tests by row on a sample size of (3-6).  I didn't see your post in R-help.
>>>>>>>
>>>>>>>
>>>>>>>________________________________
>>>>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>Sent: Saturday, April 27, 2013 8:40 AM
>>>>>>>
>>>>>>>Subject: Re: question
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>I know and I agree, but I haven´t more data. I need to use only this. In general I haven't normal data, but with this code...I prove that. I can´t have more data in the moment....
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>2013/4/27 arun <smartpink111 at yahoo.com>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>My question about normality was based on the discussion on the list.  It doesn't look right to me to do normality test on 3-6 observations.  The sample size is very low to get even remotely trust the result of that test.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>________________________________
>>>>>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>Sent: Saturday, April 27, 2013 8:15 AM
>>>>>>>>Subject: Re: question
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>Hi. Soory this long time, but I only now I see some of things that you told me.
>>>>>>>>
>>>>>>>>Your question is if I'm applying the correct test for the normality? Between kolmogorov smirnov or shapiro.test?
>>>>>>>>
>>>>>>>>Ok, I'm confirming this, but the other part of the code is the same...
>>>>>>>>
>>>>>>>>If they are normal...I need to apply normal test, if not, I need to apply not normal tests...
>>>>>>>>
>>>>>>>>I answer your question?
>>>>>>>>Sorry, but I didn´t understand correctly what is the problem.
>>>>>>>>
>>>>>>>>Thank you
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>2013/4/24 arun <smartpink111 at yahoo.com>
>>>>>>>>
>>>>>>>>So, what do you think about the normality measurement.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>----- Original Message -----
>>>>>>>>>From: arun <smartpink111 at yahoo.com>
>>>>>>>>>To: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>Cc:
>>>>>>>>>
>>>>>>>>>Sent: Tuesday, April 23, 2013 11:01 AM
>>>>>>>>>Subject: Re: question
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>Also,
>>>>>>>>>Just by looking at your function:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>test<-function(quantity, FacGroup){
>>>>>>>>> groups<-quantity[,4:ncol(quantity)]
>>>>>>>>> print(head(groups))
>>>>>>>>> #testing normality of each row
>>>>>>>>> normality<-apply(groups,1,function(x) if(length(unique(x))==1) 0 else shapiro.test(x)$p.value)
>>>>>>>>> print(head(normality))
>>>>>>>>> #if more than 50% is normal, consider all normal
>>>>>>>>> length.normality<-length(normality[normality>0.05])
>>>>>>>>> length.groups<-nrow(groups)
>>>>>>>>> a<-length(unique(FacGroup[FacGroup!=0]))
>>>>>>>>> print(head(a))
>>>>>>>>>#condition to see the best test
>>>>>>>>>if(a<=2){
>>>>>>>>> if(length.normality>0.5*(length.groups)){
>>>>>>>>>  "t.test"} else {
>>>>>>>>>  c("wilcox.test", "chisq.test")
>>>>>>>>>  }
>>>>>>>>> } else{
>>>>>>>>> if(length.normality>0.5*(length.groups)){
>>>>>>>>> "anova"} else {
>>>>>>>>> c("kruskal.test","chisq.test")
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>}
>>>>>>>>>
>>>>>>>>> 
>>>>>>>>>
>>>>>>>>>Here you are testing normality for each row.  The number of observations in each row is ??
>>>>>>>>>test1<-test(Specc, FacGroup)
>>>>>>>>>  c2 c3 c4 t2 t3 t4
>>>>>>>>>1  1  0  1  1  1  1
>>>>>>>>>2  0  0  1  0  0  1
>>>>>>>>>3  1  0  0  0  0  0
>>>>>>>>>4  2  1  1  2  1  1
>>>>>>>>>5  0  0  0  0  1  0
>>>>>>>>>6  0  0  0  1  0  1
>>>>>>>>>[1] 2.072924e-05 1.350753e-03 2.072924e-05 1.350753e-03 2.072924e-05
>>>>>>>>>[6] 1.350753e-03
>>>>>>>>>[1] 2
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>You need to look at this link:
>>>>>>>>>http://stats.stackexchange.com/questions/13983/is-it-meaningful-to-test-for-normality-with-a-very-small-sample-size-e-g-n
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>________________________________
>>>>>>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>Sent: Tuesday, April 23, 2013 10:44 AM
>>>>>>>>>Subject: Re: question
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>Ok. Thank you
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>According to your test() output, you get two choices.  "wilcox.test", "chisq.test", or "anova", .....  In the dataset you gave, I got the option "chisq.test" and "wilcox.test".  So, once you get the confirmation of chisq.test() (from experts), I can look into this new function.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>________________________________
>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>Sent: Tuesday, April 23, 2013 10:37 AM
>>>>>>>>>>
>>>>>>>>>>Subject: Re: question
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>Ok. I confirm it (but I think it's ok). You can help in other tests? wilcox.test, anova, kruskal.test.
>>>>>>>>>> 
>>>>>>>>>>Thank you
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>You have to confirm it.  I am not going to spend time on something which may not be true.  May be you can post a question on R-help with this matrix and ask whether it is okay to compare between two rows when the row data correspond to two groups.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>matrix(c(1,2,1,1,0,2),2,3,byrow=TRUE)
>>>>>>>>>>>    [,1] [,2] [,3]
>>>>>>>>>>>[1,]    1    2    1
>>>>>>>>>>>[2,]    1    0    2
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>According to ?chisq.test()
>>>>>>>>>>>     ‘chisq.test’ performs chi-squared contingency table tests and
>>>>>>>>>>>     goodness-of-fit tests.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>________________________________
>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>Sent: Tuesday, April 23, 2013 10:29 AM
>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>But I think that it isn't necessary a contingency table...
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>
>>>>>>>>>>>Yes, but if you compare the matrix dataset in the example, the chisq.test() done on that, this is not a contingency table. 
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>________________________________
>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>Sent: Tuesday, April 23, 2013 10:20 AM
>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>my null hyppothesis is campare if the 2 groups has the same distribution
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>
>>>>>>>>>>>>Check here:
>>>>>>>>>>>>>http://www.math.wustl.edu/~victor/classes/ma322/r-eg-20.txt
>>>>>>>>>>>>>
>>>>>>>>>>>>># CHI-SQUARED test for independence
>>>>>>>>>>>>>#
>>>>>>>>>>>>># Read the contingency table, r=2 rows (X values), c=3 columns (Y values):
>>>>>>>>>>>>>data<-scan()
>>>>>>>>>>>>> 163     135     71
>>>>>>>>>>>>>  86      77     40
>>>>>>>>>>>>>
>>>>>>>>>>>>>tab <- t(matrix(data, nrow=3,ncol=2))  # transpose, as usual
>>>>>>>>>>>>>tab         # view the table to make sure it is right
>>>>>>>>>>>>>        [,1] [,2] [,3]
>>>>>>>>>>>>>   [1,]  163  135   71
>>>>>>>>>>>>>   [2,]   86   77   40
>>>>>>>>>>>>>
>>>>>>>>>>>>>chisq.test(tab)   # performs a test of independence for matrix input.
>>>>>>>>>>>>>
>>>>>>>>>>>>>          Pearson's Chi-squared test
>>>>>>>>>>>>>
>>>>>>>>>>>>>  data:  tab
>>>>>>>>>>>>>  X-squared = 0.1769, df = 2, p-value = 0.9153
>>>>>>>>>>>>>
>>>>>>>>>>>>># ==> DO NOT REJECT the null hypothesis that X,Y are independent
>>>>>>>>>>>>>
>>>>>>>>>>>>># NOTE: the transposed table gives the same result, as X and Y are
>>>>>>>>>>>>># independent if and only if Y and X are independent.
>>>>>>>>>>>>>chisq.test(t(tab))
>>>>>>>>>>>>>
>>>>>>>>>>>>>          Pearson's Chi-squared test
>>>>>>>>>>>>>
>>>>>>>>>>>>>  data:  t(tab)
>>>>>>>>>>>>>  X-squared = 0.1769, df = 2, p-value = 0.9153
>>>>>>>>>>>>>
>>>>>>>>>>>>>Here, I don't  your dataset is a contingency table.  What's your null hypothesis? COmpare that with the one showed here.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>Sent: Tuesday, April 23, 2013 10:06 AM
>>>>>>>>>>>>>
>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>Yes, sorry, Your is correct
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>
>>>>>>>>>>>>>matrix(c(1,2,1,1,0,2),2,3)
>>>>>>>>>>>>>>     [,1] [,2] [,3]
>>>>>>>>>>>>>>[1,]    1    1    0
>>>>>>>>>>>>>>[2,]    2    1    2
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>This matrix is not making sense.
>>>>>>>>>>>>>> matrix(c(1,2,1,1,0,2),2,3,byrow=TRUE)
>>>>>>>>>>>>>>     [,1] [,2] [,3]
>>>>>>>>>>>>>>[1,]    1    2    1
>>>>>>>>>>>>>>[2,]    1    0   
>>>>>>>>>>>>> 2
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>Sent: Tuesday, April 23, 2013 9:58 AM
>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>We need a matrix with this. chisq.test(matrix(c(1,2,1,1,0,2),2,3)) is correct
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>First you tell me.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>chisq.test(c(1,2,1),c(1,0,2)) #is correct or not?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>Sent: Tuesday, April 23, 2013 9:36 AM
>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>yes, the function test is ok. And in this case I need to apply a chisq.test and a wilcox.test. But I could have some cases (with other group of data) that the result is other tests.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>I need to construct a new function(testFunction) that apply the results of the test (if is chisq.test and wilcox.test apply this or if is a t.test aplly this and so on).
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>Each row has 6 numbers, the 3 first is of the group c and the others of the group t. If I have 1   2   1  1   0   2, I want to aplly the test between 1  2 1   and  1   0   2. You understand?
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>Thank you
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>I guess you mentioned that
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>test() function is okay.
>>>>>>>>>>>>>>>>If I remember correctly, you were getting the results from test() function as "chisq.test" and some other test.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>I also remember providing a lapply function
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>Sent: Tuesday, April 23, 2013 9:22 AM
>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>Ok. I think I have the code to apply a chisq.test that you sent me in some time ago. I will test. I'm trying to do a function (testFunction) aplly the correct test depends of the function test. If you could give some help...thank you
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>First, you tell me what exactly you wanted to do in a  simple vector example.  Before doing that, please google chisq.test() and see if your approach makes sense.  Sorry, I don't have time to do these things.
>>>>>>>>>>>>>>>>>Thanks
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>Sent: Tuesday, April 23, 2013 9:12 AM
>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>For what? I don't understand what you are talking about...sorry
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>Please check ?chisq.test() before you ask for such comparisons.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>Sent: Tuesday, April 23, 2013 9:06 AM
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>I don't want the sum. I want to compere the frequencies of 2 groups (in this case c and t)
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>2013/4/23 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>Hi Vera,
>>>>>>>>>>>>>>>>>>>Did you got the script? Also, do you want to take the sum of the numbers for each group ("c", "t","a") and compare them?
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>Sent: Monday, April 22, 2013 7:02 PM
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>I don't remember this but I will see in emails.
>>>>>>>>>>>>>>>>>>>Thank you very much.
>>>>>>>>>>>>>>>>>>>No dia 22 de Abr de 2013 23:53, "arun" <smartpink111 at yahoo.com> escreveu:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>It is easy to adapt.  DO you have the script that I wrote for the chisq.test.  I remember doing something like TRUE or FALSE if there are warnings or not. 
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>Sent: Monday, April 22, 2013 6:47 PM
>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>yes,you did for the chisq.test. I need for the other. Is easy to adapt? i don't understand what you said about T or F. I want a new column with this,to give if the test in this row is correct or not.
>>>>>>>>>>>>>>>>>>>>No dia 22 de Abr de 2013 23:28, "arun" <smartpink111 at yahoo.com> escreveu:
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>Hi,
>>>>>>>>>>>>>>>>>>>>>I think I have done a similar script for comparisons between groups in the past.  Isn't it?  Also, with flags of TRUE/ FALSE as separate column
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>Sent: Monday, April 22, 2013 6:22 PM
>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>oh,I need the pvalue by rows but betweem groups too. in this case,between c and t
>>>>>>>>>>>>>>>>>>>>>No dia 22 de Abr de 2013 22:59, "arun" <smartpink111 at yahoo.com> escreveu:
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>Ok, that is possible.  What I don't understand is the relevance of that p-value.  What does that p-value tells you?  You had 6 groups and you got a p value with chisquare test.
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>Sent: Monday, April 22, 2013 5:50 PM
>>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>I think that you didn´t understand what I mean.
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>With the code that you sent me we have a lot of p values. It's possible to write this pvalues in front of each row (in other column) and in another the tru or false of the warnings? Like this
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>                     observations                .pvalue        warning
>>>>>>>>>>>>>>>>>>>>>>Row 1       1    2    1    1   0   1      0.0000221        TRUE
>>>>>>>>>>>>>>>>>>>>>>Row2        0    1   2    0    2   1      0.42321            False
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>...
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>You understand?
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>2013/4/22 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>Since you have many columns a1, a2, c1, c2, c3, t1, t2, the pair wise comparisons will be:
>>>>>>>>>>>>>>>>>>>>>>>vec1<- c("a1","a2","c1","c2","c3","t1","t2")
>>>>>>>>>>>>>>>>>>>>>>> t(combn(vec1,2))
>>>>>>>>>>>>>>>>>>>>>>>      [,1] [,2]
>>>>>>>>>>>>>>>>>>>>>>> [1,] "a1" "a2"
>>>>>>>>>>>>>>>>>>>>>>> [2,] "a1" "c1"
>>>>>>>>>>>>>>>>>>>>>>> [3,] "a1" "c2"
>>>>>>>>>>>>>>>>>>>>>>> [4,] "a1" "c3"
>>>>>>>>>>>>>>>>>>>>>>> [5,] "a1" "t1"
>>>>>>>>>>>>>>>>>>>>>>> [6,] "a1" "t2"
>>>>>>>>>>>>>>>>>>>>>>> [7,] "a2" "c1"
>>>>>>>>>>>>>>>>>>>>>>> [8,] "a2" "c2"
>>>>>>>>>>>>>>>>>>>>>>> [9,] "a2" "c3"
>>>>>>>>>>>>>>>>>>>>>>>[10,] "a2" "t1"
>>>>>>>>>>>>>>>>>>>>>>>[11,] "a2" "t2"
>>>>>>>>>>>>>>>>>>>>>>>[12,] "c1" "c2"
>>>>>>>>>>>>>>>>>>>>>>>[13,] "c1" "c3"
>>>>>>>>>>>>>>>>>>>>>>>[14,] "c1" "t1"
>>>>>>>>>>>>>>>>>>>>>>>[15,] "c1" "t2"
>>>>>>>>>>>>>>>>>>>>>>>[16,] "c2" "c3"
>>>>>>>>>>>>>>>>>>>>>>>[17,] "c2" "t1"
>>>>>>>>>>>>>>>>>>>>>>>[18,] "c2" "t2"
>>>>>>>>>>>>>>>>>>>>>>>[19,] "c3" "t1"
>>>>>>>>>>>>>>>>>>>>>>>[20,] "c3" "t2"
>>>>>>>>>>>>>>>>>>>>>>>[21,] "t1" "t2"
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>Sent: Monday, April 22, 2013 5:33 PM
>>>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>It´s possible to do that with one column with p value of the test and other column with true or false (if the row has warning or not)?
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>Thank you
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>2013/4/22 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>Hi,
>>>>>>>>>>>>>>>>>>>>>>>>What do you want to do with that?
>>>>>>>>>>>>>>>>>>>>>>>>You tested by rows.  Do you need pairwise comparisons??
>>>>>>>>>>>>>>>>>>>>>>>>It could be done.  But, there could be warnings() as there is only observation per group.
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>Sent: Monday, April 22, 2013 5:26 PM
>>>>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>You could give me some help with this?
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>2013/4/22 Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>Ohh, ok. I think it's some not very correct...the test need to be applied by row but consider the group too (in the case that I sent you is (c2,c3,c4,t2,t3,t4)...
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>2013/4/22 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>Regarding the warnings:
>>>>>>>>>>>>>>>>>>>>>>>>>>First of all, I am not sure what you are testing.  For example, you are testing by each row.  But you have at least 5 categories (A1, A2, C2, C3, T1, etc..). and you use tests like chi.sq.test etc.  I have hard time to understand the rationale in this. 
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>I also discussed the warnings() with you previously regarding t.test.
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>Sent: Monday, April 22, 2013 11:00 AM
>>>>>>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>Hi,
>>>>>>>>>>>>>>>>>>>>>>>>>>I just tested your suggestion. I need to put this in a function, but I will do after.
>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>It's possivel to have the number of warnings? Or the number of the rows when the test is true? Because in the function test1 we decide to apply a test if it´s possible in more than 50%, but it's good if I have this number...
>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>Thank you. But I'm thinking and asking... 
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>2013/4/21 Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>---------- Forwarded message ----------
>>>>>>>>>>>>>>>>>>>>>>>>>>>From: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>Date: 2013/4/21
>>>>>>>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>>>>>>>To: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>Hi,
>>>>>>>>>>>>>>>>>>>>>>>>>>>I tried the same with the new dataset.
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>#Using the changed test
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>test<-function(quantity, FacGroup){
>>>>>>>>>>>>>>>>>>>>>>>>>>> groups<-quantity[,4:ncol(quantity)]
>>>>>>>>>>>>>>>>>>>>>>>>>>> print(groups)
>>>>>>>>>>>>>>>>>>>>>>>>>>> #testing normality of each row
>>>>>>>>>>>>>>>>>>>>>>>>>>> normality<-apply(groups,1,function(x) if(length(unique(x))==1) 0 else shapiro.test(x)$p.value)
>>>>>>>>>>>>>>>>>>>>>>>>>>> print(normality)
>>>>>>>>>>>>>>>>>>>>>>>>>>> #if more than 50% is normal, consider all normal
>>>>>>>>>>>>>>>>>>>>>>>>>>> length.normality<-length(normality[normality>0.05])
>>>>>>>>>>>>>>>>>>>>>>>>>>> length.groups<-nrow(groups)
>>>>>>>>>>>>>>>>>>>>>>>>>>> a<-length(unique(FacGroup[FacGroup!=0]))
>>>>>>>>>>>>>>>>>>>>>>>>>>> print(a)
>>>>>>>>>>>>>>>>>>>>>>>>>>>#condition to see the best test
>>>>>>>>>>>>>>>>>>>>>>>>>>>if(a<=2){
>>>>>>>>>>>>>>>>>>>>>>>>>>> if(length.normality>0.5*(length.groups)){
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>  "t.test"} else {
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>  c("wilcox.test", "chisq.test")
>>>>>>>>>>>>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>> } else{
>>>>>>>>>>>>>>>>>>>>>>>>>>> if(length.normality>0.5*(length.groups)){
>>>>>>>>>>>>>>>>>>>>>>>>>>> "anova"} else {
>>>>>>>>>>>>>>>>>>>>>>>>>>> c("kruskal.test","chisq.test")
>>>>>>>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>>>>>>>>}
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>The output I am getting is:
>>>>>>>>>>>>>>>>>>>>>>>>>>>test1<-test(Specc, FacGroup)
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>test1
>>>>>>>>>>>>>>>>>>>>>>>>>>>#[1] "wilcox.test" "chisq.test"
>>>>>>>>>>>>>>>>>>>>>>>>>>>You didn't answer my question.
>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>About what I need with test1? Test1 is the results os the function "test",  to apply after one or two tests (I think this is your question, if I understand).
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>"
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>After that, I want in the next function "testFunction" apply the test of the results "test"."
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>What does this mean?  If I understand this, I guess you need to apply both tests "wilcox.test", "chisq.test" on each row of the Specc.
>>>>>>>>>>>>>>>>>>>>>>>>>>>Yes, I need to apply the both test by each row
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>You can apply this  as I showed on the previous email.
>>>>>>>>>>>>>>>>>>>>>>>>>>>res<- lapply(test1,function(testNew) apply(Specc[,-c(1:3)],1,function(x) get(testNew)(x)$p.value))
>>>>>>>>>>>>>>>>>>>>>>>>>>> lapply(res,head)
>>>>>>>>>>>>>>>>>>>>>>>>>>>#[[1]]
>>>>>>>>>>>>>>>>>>>>>>>>>>>#[1] 0.03688843 0.34577859 1.00000000 0.03054485 1.00000000 0.34577859
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>#[[2]]
>>>>>>>>>>>>>>>>>>>>>>>>>>>#[1] 0.9625658 0.5494160 0.4158802 0.9625658 0.4158802 0.5494160
>>>>>>>>>>>>>>>>>>>>>>>>>>>str(res)
>>>>>>>>>>>>>>>>>>>>>>>>>>>List of 2
>>>>>>>>>>>>>>>>>>>>>>>>>>> $ : num [1:29429] 0.0369 0.3458 1 0.0305 1 ...
>>>>>>>>>>>>>>>>>>>>>>>>>>> $ : num [1:29429] 0.963 0.549 0.416 0.963 0.416 ...
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>I will try this. Thank you
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>>>>>>>>> From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>Sent: Sunday, April 21, 2013 2:58 PM
>>>>>>>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>Hi. It's better you run with the data in attach.
>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>The function "test" gives the test that are more applications. After that, I want in the next function "testFunction" apply the test of the results "test".
>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>You understand what I want?
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>2013/4/21 arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>The output of test1 is puzzling.
>>>>>>>>>>>>>>>>>>>>>>>>>>>> test1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#[1] "wilcoxon.test" "qui.square"  
>>>>>>>>>>>>>>>>>>>>>>>>>>>>It only had two entries.  So, according to the testFunction, you are applying this test1 result to rows of the Specc.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Could you tell me what exactly does the result of test1 tell you?  Suppose, there are three entries "wilcox.test, "chisq.test" (not "qui schare") and "anova", then when you do this apply, it will not work.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Even if I use the first entry from "test1", it will not work.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>testFunction(Specc,test1[1])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#Error in get(as.character(FUN), mode = "function", envir = envir) :
>>>>>>>>>>>>>>>>>>>>>>>>>>>> # object 'wilcoxon.test' of mode 'function' was not found
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Because there is no "wilcoxon.test".
>>>>>>>>>>>>>>>>>>>>>>>>>>>>It should be "wilcox.test"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#Just for testing
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>apply(Specc,1,wilcox.test)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#Error in wilcox.test.default(newX[, i], ...) : 'x' must be numeric
>>>>>>>>>>>>>>>>>>>>>>>>>>>>apply(Specc[,-c(1:3)],1,wilcox.test) #works with some warnings
>>>>>>>>>>>>>>>>>>>>>>>>>>>>apply(Specc[,-c(1:3)],1,chisq.test)#works
>>>>>>>>>>>>>>>>>>>>>>>>>>>>apply(Specc[,-c(1:3)],1,get("chisq.test"))#works
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>test1<- c("wilcox.test","chisq.test")
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>apply(Specc[,-c(1:3)],1,get(test1[1]))#works
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>----- Original Message -----
>>>>>>>>>>>>>>>>>>>>>>>>>>>>From: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>To: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Cc:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Sent: Sunday, April 21, 2013 10:56 AM
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Subject: Re: question
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Hi Vera,
>>>>>>>>>>>>>>>>>>>>>>>>>>>>In the 'dados' directory, that I had, there are only 7 files.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>ReadDir<-function(FacGroup){
>>>>>>>>>>>>>>>>>>>>>>>>>>>> list.new<-lista[FacGroup!=0]
>>>>>>>>>>>>>>>>>>>>>>>>>>>> read.list<-lapply(list.new, function(x) read.table(x,header=TRUE, sep = "\t"))
>>>>>>>>>>>>>>>>>>>>>>>>>>>> names(read.list)<-file.list.names[FacGroup!=0]
>>>>>>>>>>>>>>>>>>>>>>>>>>>> return (read.list)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
>>>>>>>>>>>>>>>>>>>>>>>>>>>> FacGroup<-c(0,1,1,1,0,2,2) #so here I am changing the length to 7 instead of 8 elements in the code
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>lista[FacGroup!=0]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#[1] "/home/arunksa111/dados/a2/MSMS_23PepInfo.txt"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#[2] "/home/arunksa111/dados/c1/MSMS_23PepInfo.txt"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#[3] "/home/arunksa111/dados/c2/MSMS_23PepInfo.txt"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#[4] "/home/arunksa111/dados/t1/MSMS_23PepInfo.txt"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#[5] "/home/arunksa111/dados/t2/MSMS_23PepInfo.txt"
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>ListFacGroup<-ReadDir(FacGroup)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Specc<-Spec(ListFacGroup,0.05)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>head(Specc)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#                        Seq        Mod z a2 c1 c2 t1 t2
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#1          aAAAAAAAAAGAAGGR 1-n_acPro/ 2  1  0  1  1  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#2     aAAAAAAAGAAGGRGSGPGRR 1-n_acPro/ 2  0  1  0  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#3               AAAAAAAkAAK    8-K_ac/ 2  1  0  1  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#4            aAAAAAGAGPEMVR 1-n_acPro/ 2  2  0  2  1  2
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#5           aAAAAATAAAAASIR 1-n_acPro/ 2  0  1  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#6 aAAAAEQQQFYLLLGNLLSPDNVVR 1-n_acPro/ 2  1  0  1  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Here,
>>>>>>>>>>>>>>>>>>>>>>>>>>>> test1<- test(Specc,FacGroup) #this is printing the groups, normality, and length
>>>>>>>>>>>>>>>>>>>>>>>>>>>>   a2 c1 c2 t1 t2
>>>>>>>>>>>>>>>>>>>>>>>>>>>>1   1  0  1  1  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>2   0  1  0  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>3   1  0  1  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>4   2  0  2  1  2
>>>>>>>>>>>>>>>>>>>>>>>>>>>>5   0  1  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>6   1  0  1  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>7   2  1  2  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>8   0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>9   0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>10  1  1  1  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>11  1  0  1  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>12  1  0  1  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>13  0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>14  1  1  1  1  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>15  1  1  1  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>16  1  0  1  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>17  1  0  1  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>18  0  0  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>19  0  1  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>20  0  1  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>21  0  1  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>22  0  1  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>23  0  1  0  0  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>24  0  0  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>25  0  0  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>26  0  0  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>27  0  0  0  1  0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>28  0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>29  0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>30  0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>31  0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>32  0  0  0  0  1
>>>>>>>>>>>>>>>>>>>>>>>>>>>> [1] 0.0001309782 0.0001309782 0.0064700008 0.0459543180 0.0064700008
>>>>>>>>>>>>>>>>>>>>>>>>>>>> [6] 0.0064700008 0.3140395571 0.0001309782 0.0001309782 0.0064700008
>>>>>>>>>>>>>>>>>>>>>>>>>>>>[11] 0.0064700008 0.0064700008 0.0001309782 0.0000000000 0.0001309782
>>>>>>>>>>>>>>>>>>>>>>>>>>>>[16] 0.0064700008 0.0064700008 0.0001309782 0.0064700008 0.0064700008
>>>>>>>>>>>>>>>>>>>>>>>>>>>>[21] 0.0064700008 0.0064700008 0.0001309782 0.0001309782 0.0001309782
>>>>>>>>>>>>>>>>>>>>>>>>>>>>[26] 0.0001309782 0.0001309782 0.0001309782 0.0001309782 0.0001309782
>>>>>>>>>>>>>>>>>>>>>>>>>>>>[31] 0.0001309782 0.0001309782
>>>>>>>>>>>>>>>>>>>>>>>>>>>>[1] 2
>>>>>>>>>>>>>>>>>>>>>>>>>>>>> test1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>[1] "wilcoxon.test" "qui.square"  
>>>>>>>>>>>>>>>>>>>>>>>>>>>>> testFunction(Specc,test1)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Error in 4:ncol(quantity) : argument of length 0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>e, at the last part, you called a lot of places with "test".  So, I am a bit confused here.  I changed it to test1.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Here, the result of test1 didn't include "anova".
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>________________________________
>>>>>>>>>>>>>>>>>>>>>>>>>>>>From: Vera Costa <veracosta.rt at gmail.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>To: arun <smartpink111 at yahoo.com>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Sent: Sunday, April 21, 2013 7:56 AM
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Subject: question
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Hi again.
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>I will try to explain what I need, if you could help me. If not, no problem, don't be rude with me :-)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>My teacher put me a new goal by the other big problem that I ask you some times...maybe it will be the most important of my work in that lesson.
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>I put here all code with some description in red to try to explain.
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#this functions is ok, you don't need to look them
>>>>>>>>>>>>>>>>>>>>>>>>>>>>GetFileList <- function(directory,number){
>>>>>>>>>>>>>>>>>>>>>>>>>>>> setwd(directory)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> filelist1<-dir()[file.info(dir())$isdir]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>    direct<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), full.names = FALSE, recursive = TRUE)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> direct<-lapply(direct,function(x) paste(directory,"/",x,sep=""))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>    lista<-unlist(direct)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> output<- list(filelist1,lista)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> return(output)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>    }
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>ReadDir<-function(FacGroup){
>>>>>>>>>>>>>>>>>>>>>>>>>>>> list.new<-lista[FacGroup!=0]
>>>>>>>>>>>>>>>>>>>>>>>>>>>> read.list<-lapply(list.new, function(x) read.table(x,header=TRUE, sep = "\t"))
>>>>>>>>>>>>>>>>>>>>>>>>>>>> names(read.list)<-file.list.names[FacGroup!=0]
>>>>>>>>>>>>>>>>>>>>>>>>>>>> return (read.list)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Spec <- function(lista,FDR_k) {
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  list.new<-lapply(lista,function(x) within(x,{spec<- as.character(spec)}))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  split.list<-split(list.new,names(lista))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  #Data needed with FDR<FDR_k
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  seq.mod.z<-lapply(seq_along(split.list),function(i) lapply(split.list[[i]],function(x) x[x[["FDR"]]<FDR_k,c("Seq","Mod","z","spec")]))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  names(seq.mod.z)<- names(split.list)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  #insert colunm with the name of the folder
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  folder.name<-lapply(seq.mod.z,function(x) lapply(names(x),function(i) do.call(rbind,lapply(x[i],function(x) cbind(folder_name=i,x)))))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  #merge data with the same Seq, Mod and z
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  library(plyr)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  library(data.table)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  merge.data<- lapply(folder.name,function(x) lapply(x,function(x1) {x1<-data.table(x1); x1[,spec:=paste(spec,collapse=","),by=c("Seq","Mod","z")]}))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  #colunm with number of spec
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  count.spec<-lapply(merge.data,function(x) lapply(x,function(x1) {x1$counts<-sapply(x1$spec, function(x2) length(gsub("\\s", "", unlist(strsplit(x2, ",")))));x3<-as.data.frame(x1);names(x3)[6]<- as.character(unique(x3$folder_name));x3[,-c(1,5)]}))
>>>>>>>>>>>>>>>>>>>>>>>>>>>> count.specUnique<-lapply(count.spec,function(x) lapply(x,unique))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  #count spec by group (2-columns)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  spec.group<-lapply(count.specUnique,function(x) Reduce(function(...) merge(...,by=c("Seq","Mod","z"),all=TRUE),x))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>   #spec.group1<-spec.group[lapply(spec.group,length)!=0]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  #data frame with count of spec
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  res<- Reduce(function(...) merge(...,by=c("Seq","Mod","z"),all=TRUE),spec.group)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  res[is.na(res)] <- 0
>>>>>>>>>>>>>>>>>>>>>>>>>>>> res<- as.data.frame(res,stringsAsFactors=FALSE)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> res
>>>>>>>>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#this function test the normality of data by each now (the big part of rows) isn´t normal). And after I have the conditions to choice the best test. This function is ok too (I think)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>test<-function(quantity, FacGroup){
>>>>>>>>>>>>>>>>>>>>>>>>>>>> groups<-quantity[,4:ncol(quantity)]
>>>>>>>>>>>>>>>>>>>>>>>>>>>> print(groups)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> #testing normality of each row
>>>>>>>>>>>>>>>>>>>>>>>>>>>> normality<-apply(groups,1,function(x) if(length(unique(x))==1) 0 else shapiro.test(x)$p.value)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> print(normality)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> #if more than 50% is normal, consider all normal
>>>>>>>>>>>>>>>>>>>>>>>>>>>> length.normality<-length(normality[normality>0.05])
>>>>>>>>>>>>>>>>>>>>>>>>>>>> length.groups<-nrow(groups)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> a<-length(unique(FacGroup[FacGroup!=0]))
>>>>>>>>>>>>>>>>>>>>>>>>>>>> print(a)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#condition to see the best test
>>>>>>>>>>>>>>>>>>>>>>>>>>>>if(a<=2){
>>>>>>>>>>>>>>>>>>>>>>>>>>>> if(length.normality>0.5*(length.groups)){
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  "t-test"} else {
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  c("wilcoxon.test", "qui.square")
>>>>>>>>>>>>>>>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>>>>>>>>>>>>>>> } else{
>>>>>>>>>>>>>>>>>>>>>>>>>>>> if(length.normality>0.5*(length.groups)){
>>>>>>>>>>>>>>>>>>>>>>>>>>>> "ANOVA"} else {
>>>>>>>>>>>>>>>>>>>>>>>>>>>> c("Kruskal wallis","qui.square")
>>>>>>>>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#the help that need is here. If the answer of function "test" is "anova"(for example) I need too aplly this test in that function by row. Basically, the idea is in the function "test", see which test is the best, and depends of the answer, I need to apply this test in the next function (I now the next function isn't ok, it's only the idea that I need).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>testFunction<-function(data,test){
>>>>>>>>>>>>>>>>>>>>>>>>>>>>test1<-apply(data,1,tes)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>print(test1)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>directory<-"C:/Users/Vera Costa/Desktop/dados"
>>>>>>>>>>>>>>>>>>>>>>>>>>>> file.list.names<-GetFileList(directory,23) [[1]]
>>>>>>>>>>>>>>>>>>>>>>>>>>>> lista<-GetFileList(directory,23) [[2]]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#FacGroup<-c(0,1,0,2,2,0,3)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>FacGroup<-c(0,1,1,1,0,2,2,2)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>ListFacGroup<-ReadDir(FacGroup)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#zPValues(ListFacGroup,FacGroup)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#spec(file.list.names,c(0,1,1,1,0,2,2,2),0.05)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Specc<-Spec(ListFacGroup,0.05)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>#Specc<-head(Spec(ListFacGroup,0.05),30)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>test<-test(Specc, FacGroup)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>testFunction(Specc,test)
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>You could help in this? Sorry I ask again.
>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>Thank you
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>     
>>>>>>>>
>>>>>>> 
>>>>>>  
>>>>>   
>>>>
>>>          
>           



More information about the R-help mailing list