library(readxl)
Data <- read_excel("D:/MARV BS MATH/Marv 3rd year 2nd sem/Statistical Software/Data.xlsx")
View(Data)
#Answer as indicated
#1. Provide the same output provided below #1.1 First output:
library(rmarkdown)
paged_table(Data)
#1.2 Second output: #Consider the variables: In5, Ex4, TP3, and CP2
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
Data%>%
group_by(`Course Taken`)%>%
summarise(Frequency=n(), 'Mean Intrinsic5' = mean(In5), 'Mean Extrinsic4' = mean(Ex4), 'Mean TP3' = mean(TP3), 'Mean CP2' = mean(CP2))
## # A tibble: 6 x 6
## `Course Taken` Frequency `Mean Intrinsi~` `Mean Extrinsi~` `Mean TP3`
## <chr> <int> <dbl> <dbl> <dbl>
## 1 BS Biology 33 4.64 5.67 3.88
## 2 BS Civil Engineering 16 4.56 6.06 3.31
## 3 BS Electrical Engineer~ 17 4.53 5.59 3.47
## 4 BS Mathematics 33 4.52 5.64 3.55
## 5 BSED Biology 32 4.47 5.56 3.25
## 6 BSED English 32 4.41 5.56 3.91
## # ... with 1 more variable: `Mean CP2` <dbl>
Data%>%
group_by(`Course Taken`)%>%
summarise(Frequency=n(), 'Mean Intrinsic5' = mean(In5), 'Mean Extrinsic4' = mean(Ex4), 'Mean TP3' = mean(TP3), 'Mean CP2' = mean(CP2))
## # A tibble: 6 x 6
## `Course Taken` Frequency `Mean Intrinsi~` `Mean Extrinsi~` `Mean TP3`
## <chr> <int> <dbl> <dbl> <dbl>
## 1 BS Biology 33 4.64 5.67 3.88
## 2 BS Civil Engineering 16 4.56 6.06 3.31
## 3 BS Electrical Engineer~ 17 4.53 5.59 3.47
## 4 BS Mathematics 33 4.52 5.64 3.55
## 5 BSED Biology 32 4.47 5.56 3.25
## 6 BSED English 32 4.41 5.56 3.91
## # ... with 1 more variable: `Mean CP2` <dbl>
library(dplyr)
Data<-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"))
Data$In1=as.numeric(Data$In1)
Data$In2=as.numeric(Data$In2)
Data$In3=as.numeric(Data$In3)
Data$In4=as.numeric(Data$In4)
Data$In5=as.numeric(Data$In5)
#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?
Data%>%
group_by(In1.1, In2.1) %>%
summarise(count=n())
## `summarise()` has grouped output by 'In1.1'. You can override using the
## `.groups` argument.
## # A tibble: 27 x 3
## # Groups: In1.1 [7]
## In1.1 In2.1 count
## <chr> <chr> <int>
## 1 Agree Agree 17
## 2 Agree Moderately Agree 7
## 3 Agree Moderately Disagree 1
## 4 Agree Neutral 2
## 5 Agree Strongly Agree 20
## 6 Disagree Agree 2
## 7 Disagree Disagree 1
## 8 Disagree Moderately Disagree 1
## 9 Moderately Agree Agree 1
## 10 Moderately Agree Moderately Agree 13
## # ... with 17 more rows
Answer: There are no variables from ln1 that are strongly agree at the same time moderately disagree in In2.
#b. HOw many observations in Variable In2 that are strongly agree at the same time Neutral in variable In1?
Data%>%
group_by(In1.1, In2.1) %>%
summarise(count=n())
## `summarise()` has grouped output by 'In1.1'. You can override using the
## `.groups` argument.
## # A tibble: 27 x 3
## # Groups: In1.1 [7]
## In1.1 In2.1 count
## <chr> <chr> <int>
## 1 Agree Agree 17
## 2 Agree Moderately Agree 7
## 3 Agree Moderately Disagree 1
## 4 Agree Neutral 2
## 5 Agree Strongly Agree 20
## 6 Disagree Agree 2
## 7 Disagree Disagree 1
## 8 Disagree Moderately Disagree 1
## 9 Moderately Agree Agree 1
## 10 Moderately Agree Moderately Agree 13
## # ... with 17 more rows
Answer: There are 9 in Variable In2 that are strongly agree at the same time Neutral in In1.
#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.
Data$InAverage <- (Data$In1+Data$In2+Data$In3+Data$In4+Data$In5)/5
#Make two groups of the variable “Age”, #Grouping: #Group 1 with age less than 20 years old #Group 2 with age more than 22 years old
Data<-Data%>%
mutate(`Group 1` = ifelse(Age<=20,"Less than 20 years old",
ifelse(Age>=22, "NA", "NA")))%>%
mutate(`Group 2` = ifelse(Age >=22, "More than 22 years old", "NA"))
#3.1 Is there a significant difference between the two groups of age in terms of the variable “InAverage”?
res.aov2 <- aov(InAverage ~ `Group 1` + `Group 2`, data = Data)
summary(res.aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## `Group 1` 1 0.43 0.4269 0.347 0.557
## `Group 2` 1 0.27 0.2677 0.217 0.642
## Residuals 160 197.13 1.2321
The result shows that the InAverage between Group 1 and Group 2 does not statistically differ since the p-value = 0.557 and p-value = 0.642 both exceeds the 0.05 level of significance.
#Is there a significant difference among the courses taken in terms of the variable “InAverage”?
res.aov <- aov(InAverage ~ `Course Taken` , data = Data)
summary(res.aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## `Course Taken` 5 1.96 0.3913 0.314 0.904
## Residuals 157 195.87 1.2476
res.aov <- aov(InAverage ~ `Course Taken` , data = Data)
summary(res.aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## `Course Taken` 5 1.96 0.3913 0.314 0.904
## Residuals 157 195.87 1.2476
The result shows that there is no significant difference among the courses taken in terms of the variable “InAverage” since the p-value = 0.904 exceeds the 0.05 level of significance.