[R] How to extract the conf.level out of t.test() data
Romain Francois
romain.francois at dbmail.com
Tue Aug 10 09:42:03 CEST 2010
Le 09/08/10 20:39, Etienne Stockhausen a écrit :
>
> 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
You need the conf.level attribute, as in :
x <- t.test(1:10)
attr( x$conf.int, "conf.level" )
Romain
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/aAyra4 : highlight 0.2-2
|- http://bit.ly/94EBKx : inline 0.3.6
`- http://bit.ly/aryfrk : useR! 2010
More information about the R-help
mailing list