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? Thank you very much, Gang
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