I have done this:
FSH_date$BATCH <- relevel(FSH_date$BATCH, "0050820", "0060820", "0070820",
"0080820", "0090820", "0101120", "0111120", "0121320",
"0131320", "0010121", "0020121", "0030121", "0040721",
"0050721", "0060921", "0070921", "0081021", "0091021",
"0101121", "0010122", "0020122", "0030122")
I hoped to get such strict order of factor's level to scatter points but instead I got this output:
levels(FSH_date$BATCH)
[1] "0050820" "0010121" "0010122" "0020121" "0020122" "0030121" "0030122" "0040721"
[9] "0050721" "0060820" "0060921" "0070820" "0070921" "0081021" "0090820" "0091021"
[17] "0101120" "0101121" "0111120" "0121220" "0131220" "0131224" "0131225" "0131231"
[25] "0131234" "0131237" "0131243"
The order is not that I've been expecting and scatter is not correct as result. Could anyone help to solve this problem?
CodePudding user response:
Peter, thanks for answer.
the levels of factor in my output as not follow order that I set with relevel function and it makes problem to sort my date in right way.
CodePudding user response:
relevel() only moves one specified level to the top, and all the others one position down. To change the order of all levels as desired, try this:
factor(FSH_date$BATCH, levels = c("0050820", "0060820", "0070820", "0080820", "0090820", "0101120", "0111120", "0121320", "0131320", "0010121", "0020121", "0030121", "0040721", "0050721", "0060921", "0070921", "0081021", "0091021", "0101121", "0010122", "0020122", "0030122"))