Table 3. Mean accuracy and correlation matrix for all tests in Lab Sample 2, demonstrating discriminant validity.
# Load packages
library(readxl)
library(tidyverse)
# Read excel - lab 2 data
setwd("/Users/jessicahenderson/Library/CloudStorage/Dropbox/psychology/PSYC3361/face_lab/group_data")
lab_2 <- read_excel("lab_2.xlsx")
Create a new data frame with only the row variables that I need ( UNSW Overall (%), CFMT+ (%), CCMT (%), MFFT (%)) from lab_2 data.
# Extract columns 5, 11, 12, and 13 from the lab_2 data frame
combined_tests <- lab_2[, c(5, 11, 12, 13)]
# Load the 'matrixStats' package
library(matrixStats)
# Create a new column for the mean of each row
combined_tests$Mean <- rowMeans(combined_tests, na.rm = TRUE)
# Create a new column for the standard deviation (SD) of each row
combined_tests$SD <- rowSds(as.matrix(combined_tests), na.rm = TRUE)
# Create a new data frame for the table
table_data <- data.frame(
Row = c("UNSW", "CMFT+", "CCMT", "MMFFT"),
Mean = combined_tests$Mean[1:4],
SD = combined_tests$SD[1:4]
)
# Generate the table using kable()
table_output <- kable(
table_data, align = "c", col.names = c("", "Mean %", "SD %"), header = FALSE) %>%
kable_styling("striped", full_width = FALSE)
# Print the table
print(table_output)
| Mean % | SD % | |
|---|---|---|
| UNSW | 61.51255 | 6.497902 |
| CMFT+ | 69.32078 | 3.412637 |
| CCMT | 65.83686 | 3.976036 |
| MMFFT | 60.00353 | 7.466343 |