Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Order dataframe by two columns (secondary sort)

df = data.frame(A=c(2, 1, 1, 3), B=c(2, 4, 3, 1))
df
df[order(df$A),]
df[order(df$B),]
df[order(df$A, df$B),]