Hi there and happy X-Mas to all ,
From a standard table function, i want to add a % column and sort on this % criteria.
My main problem is I'd like this column appears with the % symbol, so i have to transform to numeric into character type. But of course, i can't sort properly because character variable.
Is there a way to sort this character variable "like" a numeric variable ?
dataset <- data.frame(x=c(rep("Crit1",43),rep("Crit2",10),rep("Crit3",4)))
dataset_table <- as.data.frame(table(dataset[,1]))
dataset_table[,"Pourcentage"] <- paste(round(dataset_table[,2]/sum(dataset_table[,2])*100, digits=2), "%", sep = " ")
sort(dataset_table[,3]) # shows bad order