Sort (order) data frame rows by multiple columns

I want to sort a data frame by multiple columns. For example, with the data frame below I would like to sort by column ‘z’ (descending) then by column ‘b’ (ascending): dd <- data.frame(b = factor(c(“Hi”, “Med”, “Hi”, “Low”), levels = c(“Low”, “Med”, “Hi”), ordered = TRUE), x = c(“A”, “D”, “A”, “C”), y = … Read more

How to make a great R reproducible example

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. When discussing performance with colleagues, teaching, sending a bug report or searching for guidance on mailing lists and here on Stack Overflow, a reproducible example is often asked and always helpful. What are … Read more