I'm creating a function in R for plotting and calculate an ANOVA model (because I have to repeat this operation a lot of time). I wrote this function:
response_vars = c(
'ANSIA',
'DEPRESSIONE',
'ESAURIMENTO.EMOTIVO',
'DEPERSONALIZZAZIONE',
'GRATIFICAZIONE.PERSONALE',
'STRESS.TOTALE'
)
var_plots <- function(df, var) {
print(table(df[, var]))
barplot(table(df[, var]))
par(mfrow=c(2,3))
for (resp_var in response_vars) {
boxplot(df[, resp_var]~df[, var], xlab = var, ylab = resp_var)
summary_aov <- summary(aov(df[, resp_var]~df[, var]))
print(summary_aov)
}
par(mfrow=c(1,1))
}
But when I execute the code the summary table is like this:
Can I change the label of df[, var]
rows?