My data.frame is stateData
and when I execute stateData[order(stateData$"heart failure"),]
, with heart failure
being a column name, I'm getting my dataframe back with the heart failure
column having increasing values like this:
10.0, 10.1, 10.3, 10.7, 15.0, 15.1, 15.9, 8.1, 8.3, 8.9, 9.0, 9.1
Here are details:dput(head(stateData))
heart failure = structure(c(97L, 44L, 25L, 6L, 52L, 57L ), .Label = c("10.0", "7.2", "7.3", "7.4", "7.5", "7.6", "7.7", "7.8", "7.9", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5", "8.6", "8.7", "8.8", "8.9", "9.0", "9.1", "9.2", "9.3", "9.4", "9.5", "9.6", "9.7", "9.8", "9.9", "Not Available"), class = "factor"),
Why is it not sorting it all the way?
Any help is appreciated! Thank you!
Edit: Here is my solution! I got it, thanks for all of the advice!
stateData[,"heart failure"] <- as.numeric(levels(stateData["heart failure"])[stateData[,"heart failure"]])
sortedData <- stateData[order(stateData[,"heart failure"]),]