Difficulty in specific order data

Hello,
I have a problem because I can't order my dataset as I want, I explain myself.

My dataset consists of a column: Sujet, variable, value, tache.
Thanks to this line of code I can order my data according to the task and the subject.

complete<-complete[order(complete$Subject, complete$variable, complete$Task),]. 

See the screen shot attached

However my goal is to make a classification as in this image. So a classification where the tache 1 2 3 3 4 would be consecutive for the same variable in the same Sujet.
I hope I've made myself clear,
have a good day

Sorry i forgot to insert the picture:
"However my goal is to make a classification as in this image": 44

You can use the following:

library(dplyr) 

complete %>%
   arrange(Sujet, variable, Tache) 

I already use it by an advise from one of my friend but it's still the same problem. I can't have Tache 1 2 3 4. It's always Tache 3 3 3 3 3 33 3 3 3 2 2 2 22 2 1 1 1 1 1 ect...

I don't see anything wrong with the output from your screenshots.

You said that you've used Subject, variable and Task to order them. I can't find task in the screenshot, but the others are correctly ordered. Same for the dplyr approach.

Remember that ordering happens sequentially. Initially, the 1st vector is sorted. Then, to break the ties, the 2nd vector is used, then the 3rd and so on. If you want to give importance to Tache, consider using it as the 1st vector, like complete<-complete[order(complete$Tache, complete$variable),].

If it doesn't solve your problem, please provide a REPRoducible EXample of your problem. It provides more specifics of your problem, and it helps others to understand what problem you are facing.

If you don't know how to do it, take a look at this thread:

2 Likes

Ok tank you all for your help, I solve my problem with @Yarnabrina advices.
Have a good day.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.