setwd("D:/stat")
getwd()
## [1] "D:/stat"
library(readxl)
## Warning: package 'readxl' was built under R version 4.2.3
Data<-read_excel("D:/stat//DataFinalExam.xlsx")
Data
## # A tibble: 163 × 33
##      Age Gender Course T…¹   In1   In2   In3   In4   In5   In6   In7   In8   Ex1
##    <dbl> <chr>  <chr>      <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
##  1    22 Female BS Mathem…     4     3     2     1     4     7     6     7     4
##  2    23 Female BS Biology     6     6     4     4     4     5     4     7     4
##  3    20 Female BSED Engl…     5     5     3     3     2     6     5     7     5
##  4    22 Female BSED Biol…     4     5     4     3     3     6     6     7     5
##  5    23 Male   BSED Engl…     7     6     5     5     4     6     4     7     7
##  6    22 Female BSED Biol…     6     6     6     6     6     7     7     7     7
##  7    20 Male   BS Civil …     4     5     6     2     5     7     4     1     7
##  8    21 Female BS Electr…     5     6     5     6     5     7     6     7     7
##  9    21 Female BS Mathem…     6     7     5     5     5     7     7     7     7
## 10    22 Male   BS Biology     6     7     5     6     7     7     7     7     5
## # … with 153 more rows, 21 more variables: Ex2 <dbl>, Ex3 <dbl>, Ex4 <dbl>,
## #   Ex5 <dbl>, Ex6 <dbl>, Ex7 <dbl>, Ex8 <dbl>, Ex9 <dbl>, Ex10 <dbl>,
## #   Ex11 <dbl>, TP1 <dbl>, TP2 <dbl>, TP3 <dbl>, TP4 <dbl>, TP5 <dbl>,
## #   T6 <dbl>, CP1 <dbl>, CP2 <dbl>, CP3 <dbl>, CP4 <dbl>, CP5 <dbl>, and
## #   abbreviated variable name ¹​`Course Taken`
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(rmarkdown)

1. Provide the same output provided below

1.1 First output:

Data1<-Data%>%
  group_by(`Course Taken`)%>%
  summarise(Frequency=n(), 'Mean Age' = mean(Age))
Data1
## # A tibble: 6 × 3
##   `Course Taken`            Frequency `Mean Age`
##   <chr>                         <int>      <dbl>
## 1 BS Biology                       33       21.6
## 2 BS Civil Engineering             16       21.4
## 3 BS Electrical Engineering        17       21.6
## 4 BS Mathematics                   33       21.7
## 5 BSED Biology                     32       21.5
## 6 BSED English                     32       21.6
Data1<-Data%>%
  group_by(`Course Taken`)%>%
  summarise(Frequency=n(), 'Mean Age' = mean(Age), 'SD of age' = sd(Age) )
Data1
## # A tibble: 6 × 4
##   `Course Taken`            Frequency `Mean Age` `SD of age`
##   <chr>                         <int>      <dbl>       <dbl>
## 1 BS Biology                       33       21.6       0.751
## 2 BS Civil Engineering             16       21.4       0.727
## 3 BS Electrical Engineering        17       21.6       0.618
## 4 BS Mathematics                   33       21.7       0.924
## 5 BSED Biology                     32       21.5       0.803
## 6 BSED English                     32       21.6       0.878

1.2 Second output:

Consider the variables: In4, Ex3, TP3, and CP3 that are grouped according to “course taken”

Data2<-Data%>%
  group_by(`Course Taken`)%>%
  summarise(Frequency=n(), 'Mean Intrinsic4' = mean(In4), 'Mean Extrinsic3' = mean(Ex3), 'Mean TP3' = mean(TP3), 'Mean CP3' = mean(CP3))
Data2
## # A tibble: 6 × 6
##   `Course Taken`            Frequency `Mean Intrinsic4` Mean E…¹ Mean …² Mean …³
##   <chr>                         <int>             <dbl>    <dbl>   <dbl>   <dbl>
## 1 BS Biology                       33              4.94     5.27    3.88   NA   
## 2 BS Civil Engineering             16              4.06     5.5     3.31    4.38
## 3 BS Electrical Engineering        17              4.35     5       3.47    3.71
## 4 BS Mathematics                   33              4.27     5.39    3.55    3.52
## 5 BSED Biology                     32              4.34     5.22    3.25    3.62
## 6 BSED English                     32              4.19     5.66    3.91    3.03
## # … with abbreviated variable names ¹​`Mean Extrinsic3`, ²​`Mean TP3`,
## #   ³​`Mean CP3`

Recoding the responses in Variables “In3 and In4” with the following changes

“1 for”Strongly Disagree” “2” for “Disagree” “3” for “Moderately Disagree” “4” for “Neutral” “5” for “Moderately Agree” “6” for “Agree” “7” for “Strongly Agree”

Data<-Data%>%
  mutate(In3=recode(`In3`, 
                          "1" = "Strongly Disagree", "2" ="Disagree", "3" = "Moderately Disagree", "4" = "Neutral", "5"="Moderately Agree", "6" = "Agree", "7" = "Strongly Agree"))%>%
  mutate(In4=recode(`In4`, 
                          "1" = "Strongly Disagree", "2" ="Disagree", "3" = "Moderately Disagree", "4" = "Neutral", "5"="Moderately Agree", "6" = "Agree", "7" = "Strongly Agree"))
Data$In1=as.numeric(Data$In1)
Data$In2=as.numeric(Data$In2)
Data$In3=as.numeric(Data$In3)
## Warning: NAs introduced by coercion
Data$In4=as.numeric(Data$In4)
## Warning: NAs introduced by coercion
Data$In5=as.numeric(Data$In5)

2.1 Answer the following:

a. How many observations in Variable In3 that are strongly agree and at the same time moderately disagree in variable In4?

Answer: There are no variables from In3 that are strongly agree at the same time moderately disagree in In4.

b. How many observations in Variable In3 that are strongly agree and at the same time Neutral in variable In4?

Answer: There are no variables from In3 that are strongly agree at the same time Neutral in variable In4.