rm(list=ls())
cat("\014")
dat4 = read.csv("D:/Users/cse/Downloads/dat4.csv")
attach(dat4)
head(dat4)
##   ID Company Concentration
## 1  1       A        101.09
## 2  2       A         99.95
## 3  3       A        101.37
## 4  4       A        102.94
## 5  5       A         99.78
## 6  6       A         99.78
str(dat4)
## 'data.frame':    100 obs. of  3 variables:
##  $ ID           : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Company      : chr  "A" "A" "A" "A" ...
##  $ Concentration: num  101.1 100 101.4 102.9 99.8 ...
Company=as.factor(Company)
Concentration = as.factor(Concentration)
sd(dat4$Concentration)
## [1] 1.797305
summary(dat4)
##        ID           Company          Concentration   
##  Min.   :  1.00   Length:100         Min.   : 96.02  
##  1st Qu.: 25.75   Class :character   1st Qu.: 98.89  
##  Median : 50.50   Mode  :character   Median : 99.98  
##  Mean   : 50.50                      Mean   :100.02  
##  3rd Qu.: 75.25                      3rd Qu.:101.17  
##  Max.   :100.00                      Max.   :103.97
max = 103.97
min = 96.02
max - min 
## [1] 7.95
Q1 = 98.89
Q3 = 101.17
Q3 - Q1
## [1] 2.28
hist(dat4$Concentration, main = "Distribution of Tablet Concentrations", xlab = "Concentration (mg)", breaks = 10 )

?hist
## starting httpd help server ... done
my_boxplot <- boxplot(Concentration ~ Company, 
      data = dat4, main = "Tablet Concentrations by Company",
     xlab = "Company",
     ylab = "Concentration (mg)")

outlier_values <- my_boxplot$out
print(outlier_values)
## [1] 103.53  96.02  97.22
t.test(dat4$Concentration, mu = 100)
## 
##  One Sample t-test
## 
## data:  dat4$Concentration
## t = 0.099037, df = 99, p-value = 0.9213
## alternative hypothesis: true mean is not equal to 100
## 95 percent confidence interval:
##   99.66118 100.37442
## sample estimates:
## mean of x 
##  100.0178
t.test(Concentration ~ Company, data = subset(dat4, Company %in% c("A", "B")))
## 
##  Welch Two Sample t-test
## 
## data:  Concentration by Company
## t = 1.9312, df = 64.692, p-value = 0.05784
## alternative hypothesis: true difference in means between group A and group B is not equal to 0
## 95 percent confidence interval:
##  -0.02577558  1.53172923
## sample estimates:
## mean in group A mean in group B 
##        99.91176        99.15879
# Perform ANOVA
anova_model <- aov(Concentration ~ Company, data = dat4)
# Display ANOVA table
summary(anova_model)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Company      2  55.67  27.836   10.22 9.36e-05 ***
## Residuals   97 264.13   2.723                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

remove