How to loop an ANCOVA test for multiple variables

I need help looping an ANCOVA test for multiple variables.
I was told to use this code but it is not working:

for (x in 1:length(ancovaQUEST)) {
aov(
ancovaQUEST[x~Responder+Age+BMI.0+Gender+SmokingStatus_NeverFormerNow,
data =df]
)
}

error code is
"incorrect number of dimensions"

I also try moving the ] to the right of x and I get this error:
"variable lengths differ (found for Responder)

This is my vector:
ancovaQUEST <- c(df$Nhem_a1c, df$Nalbumi_, df$Nglucose, df$Ntriglyc, df$Nhdl_cho, df$NOR001, df$Nldl_hdl, df$Nsodium_, df$Npotassi, df$Nco2_q.0, df$Nchlorid, df$Nurea_ni, df$Ncreatin, df$Ntotal_p, df$Na_g_rat, df$Nbilirub, df$Nalt_q.0, df$Niron_q., df$Nbasophi, df$Nuric_ac, df$Nldh_q.0, df$Nggt_q.0, df$Nwbc_q.0, df$Nhemoglo, df$rdw_q.0, df$Nplatele, df$Nabs_mon, df$Nabs_eos, df$Nabs_bas, df$Nmonocyt, df$NOR002, df$Nt4_tota, df$Nthyroxi, df$Nhomocys, df$Nnonhdl_ )

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.