I have a table, tble
from a dataframe, df
as below:
tble<-table(df$eye_color)
So it produces values as follows:
tble
Brown Black Green Blue
7 10 2 1
I want to define a variable that returns the row name with the max value in the table. For this example, it would be Black.
Strange, I did not find a duplicate when I search "[r] max of a table". But I remember seeing something similar.
names(tble)[which.max(tble)]