if (!require(readxl)) {
install.packages("readxl")
}
## Loading required package: readxl
## Warning: package 'readxl' was built under R version 4.3.3
library(readxl)
data <- read_excel("D:/[UNNES]/SEMESTER 3 [24 SKS]/Komputasi Statistika [3 SKS]/P6/preferensi_musik.xlsx")
head(data)
## # A tibble: 6 × 3
## user_id genre daily_listening_minutes
## <dbl> <chr> <dbl>
## 1 1 Pop 120
## 2 2 Rock 95
## 3 3 Jazz 80
## 4 4 Pop 130
## 5 5 Rock 100
## 6 6 Jazz 90
one_sample_test <- t.test(data$daily_listening_minutes, mu = 100)
one_sample_test
##
## One Sample t-test
##
## data: data$daily_listening_minutes
## t = 1.2359, df = 24, p-value = 0.2284
## alternative hypothesis: true mean is not equal to 100
## 95 percent confidence interval:
## 91.42528 134.17472
## sample estimates:
## mean of x
## 112.8
pop_jazz_test <- t.test(daily_listening_minutes ~ genre, data = subset(data, genre %in% c("Pop", "Jazz")))
pop_jazz_test
##
## Welch Two Sample t-test
##
## data: daily_listening_minutes by genre
## t = -1.6361, df = 8.665, p-value = 0.1376
## alternative hypothesis: true difference in means between group Jazz and group Pop is not equal to 0
## 95 percent confidence interval:
## -54.458532 8.902977
## sample estimates:
## mean in group Jazz mean in group Pop
## 85.0000 107.7778
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.