NCanon <- read.csv("C:/Users/Shariqa/Downloads/NC.csv")
attach(NCanon)
summary(NCanon)
## Observation Brand Price_. Megapixels
## Min. : 1.00 Length:28 Min. : 8.00 Min. :10.00
## 1st Qu.: 7.75 Class :character 1st Qu.:11.00 1st Qu.:12.00
## Median :14.50 Mode :character Median :16.00 Median :12.00
## Mean :14.50 Mean :17.54 Mean :12.86
## 3rd Qu.:21.25 3rd Qu.:20.00 3rd Qu.:14.00
## Max. :28.00 Max. :40.00 Max. :16.00
## Weight_oz Score Brand.1
## Min. :4.000 Min. :49.00 Min. :0.0000
## 1st Qu.:5.000 1st Qu.:59.00 1st Qu.:0.0000
## Median :6.000 Median :63.50 Median :0.0000
## Mean :5.821 Mean :63.36 Mean :0.4643
## 3rd Qu.:7.000 3rd Qu.:68.25 3rd Qu.:1.0000
## Max. :7.000 Max. :73.00 Max. :1.0000
str(NCanon)
## 'data.frame': 28 obs. of 7 variables:
## $ Observation: int 1 2 3 4 5 6 7 8 9 10 ...
## $ Brand : chr "Canon" "Canon" "Canon" "Canon" ...
## $ Price_. : int 33 20 30 20 18 20 20 13 13 11 ...
## $ Megapixels : int 10 12 12 10 12 12 14 10 12 16 ...
## $ Weight_oz : int 7 5 7 6 5 7 5 7 5 5 ...
## $ Score : int 73 73 72 69 69 68 67 67 66 62 ...
## $ Brand.1 : int 1 1 1 1 1 1 1 1 1 1 ...
boxplot(NCanon $Price, horizontal = TRUE, xlab= "Price")
The boxplot of the variable “Price” is positioned in the 1st quartile, and there seems to be 1 outlier value.
boxplot(NCanon $Megapixels, horizontal = TRUE, xlab= "Megapixels")
The boxplot of the variable “Megapixels” is positioned in the middle; however, the median of this variable is closer to its 1st quartile.
boxplot(NCanon $Weight_oz, horizontal = TRUE, xlab= "Weight")
The boxplot of the variable “Weight” is positioned more broadly towards the 3rd quartile.
boxplot(NCanon$Score, horizontal = TRUE, xlab= "Score")
The boxplot of the variable “Score” is positioned closer to the 3rd quartile.
nikon_prices <- NCanon $Price [NCanon $Brand == "Nikon"]
canon_prices <- NCanon $Price [NCanon $Brand == "Canon"]
t_test_result <- t.test(nikon_prices, canon_prices)
print(t_test_result)
##
## Welch Two Sample t-test
##
## data: nikon_prices and canon_prices
## t = 0.08931, df = 25.993, p-value = 0.9295
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -6.209637 6.773739
## sample estimates:
## mean of x mean of y
## 17.66667 17.38462
It seems that the p-value (0.9295) is greater than the significance level; therefore, we fail to reject the null hypothesis.
NCanon $Weight_Category <- cut(
NCanon $Weight_oz,
breaks = c(-Inf, 4, 5, 6, 7, Inf),
labels = c("Other", "Light Weight", "Light Weight", "Medium Weight", "Heavy Weight"),
include.lowest = TRUE
)
head(NCanon)
## Observation Brand Price_. Megapixels Weight_oz Score Brand.1 Weight_Category
## 1 1 Canon 33 10 7 73 1 Medium Weight
## 2 2 Canon 20 12 5 73 1 Light Weight
## 3 3 Canon 30 12 7 72 1 Medium Weight
## 4 4 Canon 20 10 6 69 1 Light Weight
## 5 5 Canon 18 12 5 69 1 Light Weight
## 6 6 Canon 20 12 7 68 1 Medium Weight
Categorized the weights into different categories with the labels “Light weights = 4,5”, “Medium weight = 6”, “Heavy weight = 7”.
anova_result <- aov(NCanon $Price ~ NCanon $Weight_Category, data = NCanon)
summary(anova_result)
## Df Sum Sq Mean Sq F value Pr(>F)
## NCanon$Weight_Category 2 221.4 110.69 1.698 0.203
## Residuals 25 1629.6 65.18
The p-value (0.203) is greater than 0.05, indicating that there is not enough evidence to reject the null hypothesis. Therefore, we do not have sufficient evidence to conclude that the average prices are different for different weight categories.