knitr::opts_chunk$set(message = FALSE, warning = FALSE, results='asis')
# load packages
library(readxl) #to read excel file
library(tidyverse) #for data manipulation, exploration, and visualisation
# read excel files into R and naming files in my working environment
setwd("/Users/jessicahenderson/Library/CloudStorage/Dropbox/psychology/PSYC3361/face_lab/group_data")
online_1 <- read_excel("online_1.xlsx")
online_2 <- read_excel("online_2.xlsx")
##Extracting and binding the “Age” columns in both data sets.
# Convert age column in online_1 data from character to numeric
online_1$AgeEntry <- as.numeric(online_1$AgeEntry)
# Rename the age column for online_1 data from AgeEntry to Age
online_1 <- rename(online_1, Age = AgeEntry)
# Extract the "Age" column from each data frame
online_1_age <- online_1[, 2]
online_2_age <- online_2[, 3]
# bind the "Age" columns together
combined_age <- bind_rows(online_1_age, online_2_age)
#Extracting and Binding the "Overall (%)" variables in each data set.
# Extract the **Overall (%)** column from each data frame
online_1_overall <- online_1[, 8]
online_2_overall <- online_2[, 8]
# bind the **Overall (%)** columns together
combined_overall <- bind_rows(online_1_overall,online_2_overall)
#Extracting and Binding the "Memory%" variables in each data set.
# Extract the **Memory%** column from each data frame
online_1_memory <- online_1[, 15]
online_2_memory <- online_2[, 17]
# bind the **Memory%** columns together
combined_memory <- bind_rows(online_1_memory, online_2_memory)
#Extracting and Binding the **Sorting%** variables in each data set.
# Extract the "Sort%" column from each data frame
online_1_sorting <- online_1[, 23]
online_2_sorting <- online_2[, 26]
# bind the "Sort%" columns together
combined_sorting <- bind_rows(online_1_sorting,online_2_sorting)
#bootstrapping package
library(boot)
# Bootstrapping method for overall_combined df
boot_func <- function(data, combined_overall){
sample_data <- data[combined_overall] # Sample with replacement
mean_value <- mean(combined_overall) # Calculate the mean of the column
return(mean_value)}
boot_overall <- boot(data = combined_overall$`Overall (%)`, statistic = boot_func, R = 200)
#Bootstrapping method for memory_combined df
boot_func <- function(data, combined_memory){
sample_data <- data[combined_memory] # Sample with replacement
mean_value <- mean(combined_memory) # Calculate the mean of the column
return(mean_value)}
boot_memory <- boot(data = combined_memory$`Memory%`, statistic = boot_func, R = 200)
#Bootstrapping method for combined_sorting df
boot_func <- function(data, combined_sorting){
sample_data <- data[combined_sorting] # Sample with replacement
mean_value <- mean(combined_sorting) # Calculate the mean of the column
return(mean_value)}
boot_sorting <- boot(data = combined_sorting$`Sort%`, statistic = boot_func, R = 200)
“We computed estimated peak accuracy and standard error by fitting a quadratic function to the logarithm of age and then using a bootstrapping resampling procedure, resampling from the data with replacement 200 times. The estimated age of peak accuracy for the UNSW Face Test is 30.7 years (SE = 0.2),
Note: Size and shade of each data point show the number of participants in that age group.