Error looping the ANOVA test in R in dataframe

I have the dataframe: sub3 <- df1[, c(‘Attrition’, "Age", "DistanceFromHome", "MonthlyIncome", "NumCompaniesWorked", "PercentSalaryHike", "TotalWorkingYears", "TrainingTimesLastYear", "YearsAtCompany", "YearsSinceLastPromotion", "YearsWithCurrManager")] sub3 Where Attrition is the response variable. I am trying to run a loop of ANOVA test in R to validate the relation between my response variable and the categorical ones, my code is: df_num <- function(x)… Read More Error looping the ANOVA test in R in dataframe

Is there a way to loop through column names (not numbers) in r for linear models?

I have a data sheet with 40 data columns (40 different nutrients), with additional columns for plot numbers and factors. I would like to automatically loop through each column name and produce a linear model and summary for each. The data columns begin at column 10. for(i in 10:ncol(df)) { # for-loop over columns mod2<-aov(i~block+tillage*residue+Error(subblock),data=df)… Read More Is there a way to loop through column names (not numbers) in r for linear models?

Running ANOVAs across columns within a dataframe

I have the following data frame: df<- structure(list(Group.1 = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), BLC = c(10.9890294366989, 7.31930466605672, 13.6185172644819, 2.7266530334015, 3.53565114908662, 7.20597804412166, 2.78164116828929, 7.59371098030222, 14.7343839844163, 2.9806259314456, 5.07619453154234, 6.88503820786366, 12.2882487654356, 1.40646976090014,… Read More Running ANOVAs across columns within a dataframe