i have the following data frame
dd <- data.frame(b = c("High", "Medium", "Highest", "Low", "Not bad","Good", "V. Good"),
x = c("C3", "C1", "C4", "N2", "C2", "N1","N4"), x = c("5", "2", "3", "6", "7", "5","7") )
so i want the data frame to be transformed using a manual order for the variable X.
for example: that’s the original one
1 High C3 5
2 Medium C1 2
3 Highest C4 3
4 Low N2 6
5 Not bad C2 7
6 Good N1 5
7 V. Good N4 7
but what i want is a new data frame to begin based on the value of X but not alphabetically, but randomly in an order which i chose e.g:
the first row has x=C1, the second have x=C2, the third have x=N4, ...etc
how this can be done??
thank you
Since the
xcolumn is a factor,you can simply ensure that its levels are in the order you want.