[R] A simple question

Duncan Murdoch murdoch at stats.uwo.ca
Tue Jul 17 21:57:42 CEST 2007


On 7/17/2007 3:36 PM, Gang Chen wrote:
> Hi all,
> 
> I am a newbie of R, and have a very simple question. When I run the  
> following t test
> 
> result = t.test(weight ~ group)
> 
> If I want to get the t value, I can do
> 
> tvalue = result$statistic
> 
> with tvalue being the following:
> 
> t
> 1.191260
> 
> However, if I just want the number 1.191260, not the character "t",  
> how can I achieve that?

as.numeric(result$statistic)

will give it to you.  But the value you have is already just as useful: 
  it's just a vector with a named entry.  You can do calculations with 
it without stripping off the name.

Duncan Murdoch



More information about the R-help mailing list