Data
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
library(readxl)
Data <- read_excel("D:/Winelyn/Data.xlsx")
View(Data)
library(rmarkdown)
paged_table(Data)
Answer as indicated
1. Provide the same output provided below
1.1 First output:
Data1<-Data%>%
group_by(`Course Taken`)%>%
summarise(Frequency=n(), 'Mean Age' = mean(Age))
paged_table(Data1)
1.2 Second output:
Consider the variables: In5, Ex4, TP3, and CP2
Data2<-Data%>%
group_by(`Course Taken`)%>%
summarise(Frequency=n(), 'Mean Intrinsic5' = mean(In5), 'Mean Extrinsic4' = mean(Ex4), 'Mean TP3' = mean(TP3), 'Mean CP2' = mean(CP2))
paged_table(Data2)
Recoding the responses in Variables “In1 and In2” with the following
changes
"1 for "Strongly Disagree"
"2" for "Disagree"
"3" for "Moderately Disagree"
"4" for "Neutral"
"5" for "Agree"
"6" for "Strongly Agree"
Data3<-Data%>%
mutate(In1.1=recode(`In1`,
"1" = "Strongly Disagree", "2" ="Disagree", "3" = "Moderately Disagree", "4" = "Neutral", "5"="Agree", "6" = "Strongly Agree", "7" = "Moderately Agree"))%>%
mutate(In2.1=recode(`In2`,
"1" = "Strongly Disagree", "2" ="Disagree", "3" = "Moderately Disagree", "4" = "Neutral", "5"="Agree", "6" = "Strongly Agree", "7" = "Moderately Agree"))
paged_table(Data3)
2.1 Answer the following:
a. HOw many observations in Variable In1 that are strongly agree at the same time moderately disagree in variable In2?
b. HOw many observations in Variable In2 that are strongly agree at the same time Neutral in variable In1?
Data4<-Data%>%
group_by(`In1`, `In2`) %>%
summarise(count=n())%>%
mutate(Percentage =count/sum(count))
## `summarise()` has grouped output by 'In1'. You can override using the `.groups`
## argument.
paged_table(Data4)
3. Consider the following:
Make a new variable named as “InAverage”, InAverage is the average
of the responses in the variables In1, In2, IIn3, In4, and In5.
Make two groups of the variable “Age”,
Grouping:
Data$InAverage<-Data$In1+Data$In2+Data$In3+Data$In4+Data$In5
Data<-Data%>%
mutate(`Group 1` = ifelse(InAverage<=20,"Less than 20 years old",
ifelse(InAverage<=20, "20 years old below", "Normal")))%>%
mutate(`Group 2` = ifelse(Age>=20, "More than 20 years old", "at most 20 years old"))
Group 1 with age less than 20 years old
Data6<-Data%>%
group_by(`Group 1`, `InAverage`) %>%
summarise(count=n())%>%
mutate(Percentage =count/sum(count))
## `summarise()` has grouped output by 'Group 1'. You can override using the
## `.groups` argument.
paged_table(Data6)
Group 2 with age more than 20 years old
Data7<-Data%>%
group_by(`Group 2`, `InAverage`) %>%
summarise(count=n())%>%
mutate(Percentage =count/sum(count))
## `summarise()` has grouped output by 'Group 2'. You can override using the
## `.groups` argument.
paged_table(Data7)
3.1 Is there a significant difference between the two groups of age
in terms of the variable “InAverage”?
res.ftest <- var.test(Data$InAverage , Data$`Age`)
res.ftest
##
## F test to compare two variances
##
## data: Data$InAverage and Data$Age
## F = 47.52, num df = 162, denom df = 162, p-value < 2.2e-16
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 34.8862 64.7298
## sample estimates:
## ratio of variances
## 47.52028
4. Is there a significant difference among the courses taken in
terms of the variable “InAverage”?