Hi I'm very new to R, so I have some basic questions.
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 first question: is there an easy way to change the data type for every variable after the first at once?
But it produces the error: mutat_if is not found (currently there are no packages in use except “reader”)
The next 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.
I would try using library(dplyr) to load the dplyr package where the mutate function "lives." If you haven't used it before you may have to install it. Another way to load the dplyr package would be to do dplyr::mutate_if(), but it will only work for that specific line of code (vs. library() which will make functions from that package available throughout your script).
mutate_if(is.numeric, ~as.factor(as.character(.)))
Error in UseMethod("tbl_vars") :
no applicable method for 'tbl_vars' applied to an object of class "function"
mutate_at(vars(Clavicula_medial_r:Fibula_distal_l), ~as.integer(as.character(.)))
Error in UseMethod("tbl_vars") :
no applicable method for 'tbl_vars' applied to an object of class "c('quosures', 'list')"
Hey @Der_Blauebaer. Can you share a reproducible example (sometimes called "REPREX") of the problem? Look at the reply by andresrcs for the link to an explanation of how to do that.
Thank you, it was that simpel, just had to add
Auswertung <- Auswertung %>%
mutate_if(is.numeric, ~as.factor(as.character(.)))
to make clear what should be mutatet and whrer to save.