Exercise 3_23 Week 4 Homework Question 7

It has been generally believed that it is not feasible for men and women to be just friends. Others argue that this belief may not be true anymore since gone are the days when men worked and women stayed at home and the only way they could get together was for romance. A researcher conducts a survey on 186 students. The students are asked their sex (male or female) and if it is feasible for men and women to be just friends (yes or no). A portion of the responses is shown in the accompanying table.

library(readxl)
## Warning: package 'readxl' was built under R version 4.0.5
myData <- read_excel("Ch3_Q23_Data_File.xlsx")

myData
## # A tibble: 186 x 3
##    Student Sex    Feasible
##      <dbl> <chr>  <chr>   
##  1       1 female yes     
##  2       2 female yes     
##  3       3 female yes     
##  4       4 female yes     
##  5       5 female yes     
##  6       6 female yes     
##  7       7 female yes     
##  8       8 female yes     
##  9       9 female yes     
## 10      10 female yes     
## # ... with 176 more rows

a-1. Construct a contingency table that cross-classifies the data by Sex and Feasible. Provide the frequencies in the accompanying table.

a-2. How many of the students were female?

a-3. How many of the students felt that it was feasible for men and women to be just friends?

n =table(myData$Sex, myData$Feasible)
n
##         
##          no yes
##   female 32  68
##   male   37  49
na2 = n[1, 1]+n[1,2]
sprintf("%s students are female.", na2)
## [1] "100 students are female."
na3 = n[1,2] + n[2,2]

sprintf("%s students felt that men and women can be just friends", na3)
## [1] "117 students felt that men and women can be just friends"

###b-1. What is the likelihood that a male student feels that men and women can be just friends? (Report the proportion rounded to 2 decimal places.)

###b-2. What is the likelihood that a female student feels that men and women can be just friends? (Report the proportion rounded to 2 decimal places.)

total = n[1, 1]+ n[1,2]
p = round(n[1, 2]/total, 2)
p
## [1] 0.68

###c.ย The figure below shows the stacked column chart for the data.

barplot(n, main="Sex and Friendship",
        col = c('pink', 'blue'), legend = rownames(n), xlab='Can be friends',
        ylab = 'Count', ylim = c(0, 125))