0

Full disclosure: this is part of an assignment for the R Programming Course offered by Coursera that I am auditing.

I'm working with a dataset on hospitals accessible at this link through the course.

Essentially, I need to order the 30 day hospital mortality rate for a particular state so that the hospital with the lowest rate comes first.

Here's the code, nested throughout a larger function, I've used to do that:

data <- read.csv("rprog-data-ProgAssignment3-data/outcome-of-care-measures.csv")
state_data <- subset(data, "TX")
reord <- state_data[with(state_data, order(Hospital.30.Day.Death..Mortality..Rates.from.Heart.Failure)), ]

However, when I look at the column of reord for Hospital.30.Day.Death..Mortality..Rates.from.Heart.Failure, I see values starting at 10.0, increasing to 15.8 AND THEN the next row starts at 8.1 and increases to 9.9. It's as if the order function is ordering based on number length, and then the actual values.

Thoughts on why this is?

Community
  • 1
  • 1
zthomas.nc
  • 3,689
  • 8
  • 35
  • 49

0 Answers0