I want to create a loop that stores the output of t-tests for several variables in a data frame. But when I store the different variables in a vector with quotation marks, the variables cannot be used for the t-test as they are saved with the quotation marks. For example, R takes the first variable as "variable_1" in the loop, which produces an error because for the t-test I need the variable without the quotation marks, e.g. t.test(variable_1 ~ Gender). Does someone know how to get rid of the quotation marks of the names of the variables in a vector?
variable <- c("variable_1", "variable_2", "variable_3")
df <- data.frame(t_value=as.numeric(),
df=as.numeric(),
p_value= as.numeric(),
mean_f= as.numeric(),
mean_m= as.numeric())
attach(data)
for(v in variable){
output <- t.test(v ~ Gender)
values <- output[c(1,2,3,5)]
row <- round(unlist(values, use.names = FALSE),3)
df <- rbind(df, row)
}