Data


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

Answer as indicated

1. Provide the same output provided below

1.1 First output:

1.2 Second output:

Consider the variables: In5, Ex4, TP3, and CP2

Recoding the responses in Variables “ln1” and “ln2” with the following changes

"1 for "Strong Disagree"
"2" for "Disagree"
"3" for "Moderately Disagree"
"4" for "Neutral"
"5" for "Agree"
"6" for "Strongly Agree"
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?
    
Ian2<-Data%>%
  group_by(In1.1, In2.1) %>%
  summarise(count=n())
`summarise()` has grouped output by 'In1.1'. You can override using the
`.groups` argument.
paged_table(Ian2)

Answer: There are no variables from In1 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?
    
Ian3<-Data%>%
  group_by(In1.1, In2.1) %>%
  summarise(count=n())
`summarise()` has grouped output by 'In1.1'. You can override using the
`.groups` argument.
paged_table(Ian3)

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 ln1, ln2, lln3, ln4, and ln5.

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.427   0.354 0.5524  
`Group 2`     1   4.70   4.701   3.903 0.0499 *
Residuals   160 192.70   1.204                 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Interpretation: The result shows that the variable InAverage, only Group 2 has a significant difference since the p-value is 0.0499 which lies in the level of significance (0.05).

4. 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               

Interpretation: The result shows that there is no significant difference among the courses taken in terms of the variable “InAverage” since the p-value is 0.904 which exceeds the 0.05 significance level.