[R] How to extract the conf.level out of t.test() data
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Tue Aug 10 09:42:04 CEST 2010
try this:
x <- t.test(1:10)
x$conf.int
attr(x$conf.int, "conf.level")
I hope it helps.
Best,
Dimitris
On 8/9/2010 8:39 PM, Etienne Stockhausen wrote:
> Good afternoon everybody,
>
> I'm writing a little function to visualise hypothesis testing. Therefore
> I need to extract the confidence level of a t-test. Here a little example:
>
> x <- str(t.test(1:10)
>
> gives
>
> List of 9
> $ statistic : Named num 5.74
> ..- attr(*, "names")= chr "t"
> $ parameter : Named num 9
> ..- attr(*, "names")= chr "df"
> $ p.value : num 0.000278
> $ conf.int : atomic [1:2] 3.33 7.67
> ..- attr(*, "conf.level")= num 0.95
> $ estimate : Named num 5.5
> ..- attr(*, "names")= chr "mean of x"
> $ null.value : Named num 0
> ..- attr(*, "names")= chr "mean"
> $ alternative: chr "two.sided"
> $ method : chr "One Sample t-test"
> $ data.name : chr "1:10"
> - attr(*, "class")= chr "htest"
>
> Now I can use
>
> x$conf.int
>
> what gives
>
> [1] 496.9141 499.6276
> attr(,"conf.level")
> [1] 0.95
>
> In the example I try to extract the value 0.95 but I have no Idea how. I
> hope somebody can help me.
> Thanks in advance an greetings from Berlin
>
> Etienne
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
More information about the R-help
mailing list