4059/reordering-levels-of-a-factor-variable
I am working with the iris dataset and this is the normal ordering of levels i get w.r.t the Species column:
levels(iris$Species) [1] "setosa" "versicolor" "virginica"
I would want to change the ordering of levels to -> "virginica" "versicolor" "setosa", i.e, i want to reverse the order of levels
The factor() function provides the 'levels' attribute for this purpose:
iris$Species <- factor(iris$Species, levels =c("virginica","versicolor","setosa") )
All you have to do is, use the levels attribute and reorder the factors.
Yes, you can modify the model.matrix() function ...READ MORE
With the help of Dplyr: rename function ...READ MORE
You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE
You can use factor(ff) to drop levels ...READ MORE
We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE
You can do this using dplyr and ...READ MORE
You need not spread twice, if you ...READ MORE
By assuming that all the values are ...READ MORE
Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE ...READ MORE
To find number of missing values for ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.