I have a data frame which consists of a column of IDs and many columns with different values for each ID, many of which are NA. e.g:
ID w x y z
1 User1 3 2 NA NA
2 User2 7 9 NA 4
3 User3 NA NA 1 NA
4 User4 3 NA NA 5
Is there a way to get a list for each ID of the column headings in order from smallest to largest value with NAs removed?
For example:
User 1: x, w
User 2: z, w, x
User3: y
So far I've gotten nowhere with this. I tried just getting the order of rows with by_row like so:
ordered <- by_row(moves.df, function(order) list(order[,2:ncol(moves.df)]), .collate = "list")$.out
but the output of that was just a list of single-observation dataframes for each row which had not been ordered in any way.
ordered2 <- moves.df %>% rowwise() %>% mutate(placelist = list(rank(moves.df[,2:ncol(moves.df)])))
which gave me a column that was a list, but the list was of numbers I didn't recognise.
Any help would be super appreciated!