library(readr)
library(ggplot2)
ex9_25 <- read_csv("/Users/davidmontalvo/Desktop/ex9-25.csv")
## New names:
## * `` -> ...3
## * `` -> ...4
## Rows: 26 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): rating
## dbl (1): Price$
## lgl (2): ...3, ...4
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
str(ex9_25)
## spec_tbl_df [26 × 4] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Price$: num [1:26] 100 100 60 135 195 195 125 135 95 42 ...
## $ rating: chr [1:26] ">=93" ">=93" ">=93" ">=93" ...
## $ ...3 : logi [1:26] NA NA NA NA NA NA ...
## $ ...4 : logi [1:26] NA NA NA NA NA NA ...
## - attr(*, "spec")=
## .. cols(
## .. `Price$` = col_double(),
## .. rating = col_character(),
## .. ...3 = col_logical(),
## .. ...4 = col_logical()
## .. )
## - attr(*, "problems")=<externalptr>
qqnorm(ex9_25$`Price$`)+stat_qq_line()+stat_qq()
## NULL
ggplot(ex9_25) + geom_boxplot(aes(y = `Price$`)) +
facet_wrap(~rating)
## The variables prove to have normal distribution based on their linear distribution
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
H <- ex9_25 %>% filter(rating == ">=93") %>% select("Price$")
P <- ex9_25 %>% filter(rating == "<=89") %>% select("Price$")
t.test(x = H$`Price$`, y = P$`Price$`, alternative = c("two.sided"))
##
## Welch Two Sample t-test
##
## data: H$`Price$` and P$`Price$`
## t = 3.1744, df = 15.426, p-value = 0.006106
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 16.19010 81.88133
## sample estimates:
## mean of x mean of y
## 110.75000 61.71429
#Sample mean: X¯=110.75,Y¯=61.71429
#Two sided confidence interval: P(16.19010<μ1−μ2<81.88133)=0.95
#Degree of freedom: 15.426.
#Test statistic: t=3.1744
#P-value: 0.006106.
#Conclusion: at α=0.05, fail to reject the null hypothesis. The two groups are statistically significant.