-1

I have the following dataset

enter image description here

and I would like the order in the "Crowding" column to be the following: "Uncrow", "CrowGr", "CrowUng".

Phil
  • 7,287
  • 3
  • 36
  • 66
  • Please don't post data as images. Take a look at how to make a [great reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for ways of showing data. – Martin Gal Jul 31 '21 at 15:18
  • 1
    You can do `Params_data_long$Crowding <- factor(Params_data_long$Crowding, levels = c("Uncrow", "CrowGr", "CrowUng"))` and then `Params_data_long[order(Params_data_long$Crowding), ]` – Phil Jul 31 '21 at 15:23

1 Answers1

0

Here's a simple solution using dplyr.

I've created a dummy code there to test it. Would be best in the future to post reproducible examples though for people to answer.

library(dplyr)

Params_data_long <- data.frame(Crowding = c("CrowGr", "CrowGr", "Uncrow", "CrowGr", "Uncrow","CrowUng"),
                 Participant = c(1, 2, 1, 3, 4, 2))

Params_data_long <- Params_data_long %>%
  arrange(factor(Crowding, levels = c("Uncrow", "CrowGr", "CrowUng")))
kodikai
  • 374
  • 1
  • 10