[R] A simple question

Gang Chen gangchen at mail.nih.gov
Tue Jul 17 22:37:22 CEST 2007


Thank you very much!

Gang

On Jul 17, 2007, at 3:57 PM, Duncan Murdoch wrote:

> 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