[R] return p-value in a t.test function
    arun 
    smartpink111 at yahoo.com
       
    Tue Jun  4 21:06:01 CEST 2013
    
    
  
Hi,
Try this:
set.seed(24)
 b1<- sample(1:40,20,replace=TRUE)
 set.seed(28)
 a1<- sample(30:50,20,replace=TRUE)
t_test_apparie <- function(x,y)
{
t.test(x,y,paired=TRUE,alternative = "greater")$p.value
} 
t_test_apparie(a1,b1)
#[1] 6.571404e-08
A.K.
>Hi, 
>
>I have written this function : 
>
>t_test_apparie <- function(x,y) 
>{ 
>t.test(x,y,paired=TRUE,alternative = "greater") 
>} 
>
>I would like that ONLY the p-value gets returned. How would I do that? 
>
>Thanks.
    
    
More information about the R-help
mailing list