# R programming

#### petros20

##### New Member
Hi all,
I am new in statistics and I have to do a homework.

I have to analyze some data and find confidence intervals with R program

My code is
Code:
t = read.table("http://androulakis.bma.upatras.gr/exam/cache/survey.PEZ.csv", header=T, sep=",")
attach(t)

pie3D(table(sex),explode=0.15,main="gender")
Could you help me find confidence intervals please ?
Can I paste it in pie like a legend ?

This seems like a good thread for the R subforum... - Dason

Last edited by a moderator:

#### TheEcologist

##### Global Moderator
Hi all,
I am new in statistics and I have to do a homework.

I have to analyze some data and find confidence intervals with R program
Welcome,

First make sure you have read this and this.

Could you help me find confidence intervals please ?
Before I do your work for you, how would you calculate confidence intervals by hand?

Can I paste it in pie like a legend ?
You can... but that would be an unusual way to do it.

#### Dason

I just have to say that I hate pie charts. Things I think are worse than pie charts: 3D pie-charts. Things I find worse than 3D pie-charts: Multiple 3D pie-charts

#### petros20

##### New Member
Thanks a lot for you answers

So, I understand that I have to redefine the question.

I know for finding confidence intervals we use t.test.
but I don't know what is the value of mu.
is the mean ?

Something like that :
Code:
t = read.table("http://androulakis.bma.upatras.gr/exam/cache/survey.PEZ.csv", header=T, sep=",")
attach(t)
h<-table(sex)
t.test(h[1], mu = mean(h[1]), conf.level = 0.95)
t.test(h[2], mu = mean(h[2]), conf.level = 0.95)

#### TheEcologist

##### Global Moderator
Thanks a lot for you answers

So, I understand that I have to redefine the question.

I know for finding confidence intervals we use t.test.
but I don't know what is the value of mu.
is the mean ?
Actually if the data is binomial (involves proportions) we don't use the t-test.

Here is a good overview;
http://udel.edu/~mcdonald/statbigchart.html

Look into Gtest, Chisquare, Exact binomial test, Normal approximation of the binomial.

Or in R:
?prop.test
?binom.test

You can get the confidence intervals from such a test by using:
Code:
# look at the object structure
str(binom.test(h, conf.level = 0.95))
#extract the CI's
binom.test(h, conf.level = 0.95)\$conf.int

#### petros20

##### New Member
Thanks a lot

It is exact what I want