Thank you so much to all! However, I have a question. I have performed the test with the function correlation_biserial <- cor(M1, as.numeric(gender)) and with the function of technocrat of cor.test. The results are the same and I can not see where I have said with the function cor.test that I want a biseral correlation:
Variables
variables <- c("FL_2", "FL_3", "SL_3", "SL_6", "DSLNT", "LDFT", "LNDFH_I", "LNDFH_II", "LNFP_V", "LNT", "LNnFP_V", "LNnT", "Lactose")
Diabetes- binary variable
Diabetes <- Conce_HM_$Diabetes
Loop
for (var in variables) {
correlation_pearson <- cor.test(Diabetes, Conce_HM_[[var]], method = "pearson", use = "pairwise.complete.obs")
Extract correlation coefficient and p-value
correlation_coefficient <- correlation_pearson$estimate
p_value <- correlation_pearson$p.value
Print the results
cat("Pearson's correlation between Diabetes and", var, ":\n")
cat("Correlation coefficient:", correlation_coefficient, "\n")
cat("p-value:", p_value, "\n\n")
}
I only have told that I want a Pearson correlation. I am a bit confused.