I have a dataframe called "groups", with column names "A" through "H".
Any idea what's the problem with this and how to fix it?
for(i in colnames(groups)){
print(groups$i)
}
> NULL
> NULL
> NULL
> NULL
> NULL
> NULL
> NULL
> NULL
Especifically, why is this so?
groups$"A"
> "Ecuador"
> "Netherlands"
> "Qatar"
> "Senegal"
i <- "A"
groups$i
> NULL
CodePudding user response:
Here is the solution:
for(i in 1:length(groups)){
print(groups[i])
}