I have a dataframe(df). I need to find the class of each column names in a for loop. I tried with the below code but not able to get the solution
> df
x y g
1 a 2 1
2 a 3 2
3 b 4 1
4 b 5 2
>for(i in colnames(df))
{
print(class(df$i)) }
The expected out put is
> "factor","integer","integer"
Because class of x is a factor and other 2 are integers