Confidence Intervals with R

Introduction
 

Confidence intervals for a population mean can be found with R using the command "t.test" from the base package.

Note that unlike Minitab, R requests for the original data to be given as vectors, that is, R does not accepts the summarized data (mean, sample size, sample standaard deviation) to be give. 
Instead, R does the summary itself.
 
Confidence interval for single-population mean
 
Let x represents a sample collected from a normal population with unknown mean and standard deviation. We are interested in find a 95% confidence interval for the population mean
 

>x= c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,
+            + 8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,
+            + 11.3, 11.9)                    # Interring the data into R-workspace
>test<-t.text(x)                              # Performing a t-test, the default confidence level is 95%
>test$conf.int                                # Extracting the confidence interval

 
[1] 8.292017   9.499649
 
attr(,"conf.level")
 
[1] 0.95
 
Confidence interval for two-population means
 
If we are interested in finding the confidence interval for the difference of two population means, the R-command "t.test" is also to be used.
The article "Measuring and Understanding the Aging of Kraft Insulating Paper in Power Transformers" (IIEE Electrical Insul. Mag., 1996:28-34), contained observations on degree of polymerization for paper specimens for which viscosity times concentration fell in a certain middle range x=(418,421,421,422,425,427,431,434,437,439,446,447,448,453,454,463,465) and and higher range y=(429,430,430,431,36,437,440,441,445,446,447).
 
We are interested in constructing a 90% confidence interval for the difference between the true average degree of polymerization for the middle range and for the higher range.
Since we don't anything about the two population , we will assume that they have unequal unknown variances.
 
 

>x=c(418,421,421,422,425,427,431,434,437,439,446,447,448,453,454,463,465)   # Entering the data into the R-workspace.
>y=c(429,430,430,431,36,437,440,441,445,446,447) >test2<-t.test(x,y,alternative="two.sided",mu=0,var.equal=F,conf.level=0.90)       # Performing a t-test procedure, containing a confidence interval computation
>test2$conf.int                                                             # Extracting the confidence interval

[1] -29.27264 103.67905 attr(,"conf.level")

[1] 0.9