I need to make a correlation matrix for the related selected categorical variables and numerical variables, using the function polyserial(). However, i can only call the function for two variables one time and wonder if there are any ways to write a loop that can generate the matrix for once.
df = read.csv("mydata.csv")
df2 = df %>%
select(confidence,r_med_adherence,a,b,c,d,e)
# a,b,c,d,e are the categorical variables, I like to see the correlation between them and confidence,r_med_adherence
# I can only test one by one
polyserial(df$r_med_adherence,df$a)
polyserial(df$r_med_adherence,df$b)
polyserial(df$r_med_adherence,df$c)