I'm very new with the R language, apologies for the noob question.
I'm trying to find a correlation between sex and total Usability (totalU), total Satisfaction (totalS), and total Ease of Use (totalE). Also, sexNumeric is basically Male = 1, Female = 2, vice versa.
For efficiency purposes, I'd like to learn about how you can loop this. I've tried doing:
x <- sexNumeric
z <- list(totalU,totalS,totalE)
for (i in z){
cor(x,z)
}
But it does not work, it says "Error in cor(x,z) : 'y' must be numeric."
Here is the link of the csv file: https://drive.google.com/file/d/1MlmaLGFpm94dLssMAX6oFj0_P5chuUJi/view?usp=sharing
Here is a reproducible sample:
dat <- read.csv(file = "Canva_ApplicationUsability.csv", header = TRUE)
totalU = rowSums(dat[,c(4:8)],na.rm=TRUE) #Get the sum of each respondent in Usefulness
totalS = rowSums(dat[,c(9:13)],na.rm=TRUE) #Get the sum of each respondent in Satisfaction
totalE = rowSums(dat[,c(14:18)],na.rm=TRUE) #Get the sum of each respondent in Ease of Use
#Assign Numeric Values to Characters of Sex
sexNumeric <- dat[1]
sexNumeric <- sexNumeric %>% mutate(Sex = replace(Sex, Sex == "Male", 1))
sexNumeric <- sexNumeric %>% mutate(Sex = replace(Sex, Sex == "Female", 2))
sexNumeric <- sexNumeric %>% mutate(Sex = replace(Sex, Sex == "Transgender Male", 3))
sexNumeric <- sexNumeric %>% mutate(Sex = replace(Sex, Sex == "Transgender Female", 4))
sexNumeric <- sexNumeric %>% mutate(Sex = replace(Sex, Sex == "Gender Variant/Non-Conforming", 5))
sexNumeric <- sexNumeric %>% mutate(Sex = replace(Sex, Sex == "Prefer Not to Answer", 6))
sexNumeric$Sex <- as.numeric(sexNumeric$Sex)
So yeah, those are the where sexNumeric and totalU, totalS, and totalE come from. Then, I'd like to find the correlation between sexNumeric (x) and totalU, totalS, and totalE (y) in one loop.
Thanks in advance!
Edit 1: Specifically, for every loop, I want z to be replaced by totalU, then in the next loop replaced by totalS, then in the next by totalE. Each of those variables contain values ranging from 1 to 5, it's from a Likert-scale survey.