Bernzweig, Bruce (Exchange)
2006-Mar-24 20:00 UTC
[Rd] How to capture t-score and p-values from t.test
When I do t.test on two distributions (see example below), it outputs numerous data about the t.test. What I'd like to do is individually capture some of this data and assign it to other variables. However, I am unable to find anything in the help section. In the example below, the t value is -4.0441 and the p-value is 0.006771 How can I assign these values to two variables, let's say tVal and pVal? Thanks, - Bruce> t.test(d[1], d[2], var.equal=TRUE)Two Sample t-test data: d[1] and d[2] t = -4.0441, df = 6, p-value = 0.006771 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -5.216430 -1.283570 sample estimates: mean of x mean of y 2.50 5.75 -------------- next part -------------- ********************************************************************** Please be aware that, notwithstanding the fact that the person sending this communication has an address in Bear Stearns' e-mail system, this person is not an employee, agent or representative of Bear Stearns. Accordingly, this person has no power or authority to represent, make any recommendation, solicitation, offer or statements or disclose information on behalf of or in any way bind Bear Stearns or any of its affiliates. **********************************************************************
"Bernzweig, Bruce (Exchange)" <bbernzwe at bear.com> writes:> When I do t.test on two distributions (see example below), it outputs > numerous data about the t.test. > > What I'd like to do is individually capture some of this data and assign > it to other variables. > > However, I am unable to find anything in the help section. > > > > In the example below, the t value is -4.0441 and the p-value is 0.006771 > > How can I assign these values to two variables, let's say tVal and pVal? >tt <- t.test(d[1], d[2], var.equal=TRUE) tt$statistic tt$p.value unclass(tt) names(tt) -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Bernzweig, Bruce (Exchange)
2006-Mar-24 20:42 UTC
[Rd] How to capture t-score and p-values from t.test
Thanks Peter! -----Original Message----- From: pd at pubhealth.ku.dk [mailto:pd at pubhealth.ku.dk] On Behalf Of Peter Dalgaard Sent: Friday, March 24, 2006 3:37 PM To: Bernzweig, Bruce (Exchange) Cc: r-devel at r-project.org Subject: Re: [Rd] How to capture t-score and p-values from t.test "Bernzweig, Bruce (Exchange)" <bbernzwe at bear.com> writes:> When I do t.test on two distributions (see example below), it outputs > numerous data about the t.test. > > What I'd like to do is individually capture some of this data and assign > it to other variables. > > However, I am unable to find anything in the help section. > > > > In the example below, the t value is -4.0441 and the p-value is 0.006771 > > How can I assign these values to two variables, let's say tVal and pVal? >tt <- t.test(d[1], d[2], var.equal=TRUE) tt$statistic tt$p.value unclass(tt) names(tt) -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 ********************************************************************** Please be aware that, notwithstanding the fact that the person sending this communication has an address in Bear Stearns' e-mail system, this person is not an employee, agent or representative of Bear Stearns. Accordingly, this person has no power or authority to represent, make any recommendation, solicitation, offer or statements or disclose information on behalf of or in any way bind Bear Stearns or any of its affiliates.
Kjetil Brinchmann Halvorsen
2006-Mar-25 20:57 UTC
[Rd] How to capture t-score and p-values from t.test
Bernzweig, Bruce (Exchange) wrote:> When I do t.test on two distributions (see example below), it outputs > numerous data about the t.test. > > What I'd like to do is individually capture some of this data and assign > it to other variables. > > However, I am unable to find anything in the help section.t.test returns an object of class "htest", but ?htest : > ?htest No documentation for 'htest' in specified packages and libraries: you could try 'help.search("htest")' but that does not do anythinh eiather. Some time ago, I wrote a helpfile for htest, but that was rejected, since "S3 classes are not usually documented". Kjetil> > > > In the example below, the t value is -4.0441 and the p-value is 0.006771 > > How can I assign these values to two variables, let's say tVal and pVal? > > > > Thanks, > > > > - Bruce > > > >> t.test(d[1], d[2], var.equal=TRUE) > > Two Sample t-test > > data: d[1] and d[2] > > t = -4.0441, df = 6, p-value = 0.006771 > > alternative hypothesis: true difference in means is not equal to 0 > > 95 percent confidence interval: > > -5.216430 -1.283570 > > sample estimates: > > mean of x mean of y > > 2.50 5.75 > > > > ------------------------------------------------------------------------ > > > > ********************************************************************** > Please be aware that, notwithstanding the fact that the person sending > this communication has an address in Bear Stearns' e-mail system, this > person is not an employee, agent or representative of Bear Stearns. > Accordingly, this person has no power or authority to represent, make > any recommendation, solicitation, offer or statements or disclose > information on behalf of or in any way bind Bear Stearns or any of its > affiliates. > ********************************************************************** > > > > ------------------------------------------------------------------------ > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
> Date: Sat, 25 Mar 2006 16:57:50 -0400 > From: Kjetil Brinchmann Halvorsen > <kjetilbrinchmannhalvorsen at gmail.com> > Subject: Re: [Rd] How to capture t-score and p-values from t.test > To: "Bernzweig, Bruce \(Exchange\)" <bbernzwe at bear.com> > Cc: r-devel at r-project.org > > Bernzweig, Bruce (Exchange) wrote: >> When I do t.test on two distributions (see example below), it outputs >> numerous data about the t.test. >> >> What I'd like to do is individually capture some of this data and assign >> it to other variables. >> >> However, I am unable to find anything in the help section. > > t.test returns an object of class "htest", but ?htest : > > ?htest > No documentation for 'htest' in specified packages and libraries: > you could try 'help.search("htest")' > but that does not do anythinh eiather. > > Some time ago, I wrote a helpfile for htest, but that was rejected, > since "S3 classes are not usually documented". > > KjetilThe "htest" object created by t.test() is fully documented in the "Value" section of help("t.test"). In effect, this defines what a "htest" object is understood to be. help.search("htest") brings up a list of every function which produces an "htest" object. Gordon