Task 2
best <- function(state, outcome) {
## Read outcome data
outdata <- read.csv("outcome-of-care-measures.csv", colClasses = "character")
usefuloutcome <- outdata[, c(2, 7, 13, 19, 25)]
## Check that state and outcome are valid
## Return hospital name in that state with lowest 30-day death rate
## select corespond information
## assume we need State AL attack 这里行和列的选择都要输入参数
if(outcome == "heart attack"){
i <- 3
}else if(outcome == "heart failure"){
i <- 4
}else{
i <- 5
}
useful1 <- usefuloutcome[which(usefuloutcome$State == state), c(1, i)]
useful2 <- as.numeric(useful1[, 2]