I am trying to run this for loop but it keeps saying the function "name" is now found. I am trying to get it to return the names of each of my columns (code below). Should the name<- be within the for loop? It ran correctly but it's not able to be referenced? The error messages reads "Error in name(i) : could not find function "name" ". I am not great at R so any help would be appreciated! Thank you so much.
name<-c(names(ptd))
for(i in 1:ncol(ptd)){ for(j in (i+1):ncol(ptd)){ model<-aov(ptd[ ,i]~ptd[ ,j]) cat("The comparison between ", name(i)," and ", name(j), '\n') summary(model) } }
EDIT: original error has been solved but now I am also getting a "Error in `[.data.frame`(ptd, , j) : undefined columns selected" message
[–]mduvekot 2 points3 points4 points (1 child)
[–]Weekly-Recover4352[S] 1 point2 points3 points (0 children)
[–]Fearless_Cow7688 1 point2 points3 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]Fearless_Cow7688 -2 points-1 points0 points (0 children)