Hi here is my second try, this time with a REPREX (I hope it works).
I want to sort ordinal data (a factor) from 104 observations in 43 variables (first is the Name of the Observation and 42 variables) coded as 1, 2, and 3. Naturally R thinks it is a numerical data. So I changed the Data typ.
The question would be if R can arrange the data in ascending order. It is biological data so we have overlapping and missing data. R should arrange the observations with as little overlap as possible.
Which package should be used and which commands?
My REPREX would look like this:
Ind. <- c("a", "b", "c", "d", "e", "f")
obs.1 <- c(1, 1, 2, NA, 2, 3)
obs.2 <- c(2, 2, 3, 3, 2, NA)
obs.3 <- c(1, 2, 2, NA, 3, NA)
obs.4 <- c(1, 2, 3, 3, 2, 3)
DATA <- data.frame(Ind., obs.1, obs.2, obs.3, obs.4)
library(dplyr)
DATA <- DATA %>%
mutate_if(is.numeric, ~as.factor(as.character(.)))
The Solution would look like row as a, b, c, f, d, e, an columns as Ind., obs.1, obs.3. Obs.2 and obs.4, obs.3.