-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbest.R
More file actions
26 lines (15 loc) · 704 Bytes
/
best.R
File metadata and controls
26 lines (15 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Utility functions have been extracted into another file for reuse across
## the multiple files in this assignment. Please see the following utility
## R file to explore their contents.
source(here::here("assignment_3_utilities.R"))
best <- function(state, outcome) {
readdata <- init()
validateparameters(state, outcome, unique(readdata$State))
statedata <- subset(readdata, readdata$State==state)
colnum <- colnumFor(outcome)
min_outcome <- min(as.numeric(statedata[, colnum]), na.rm = TRUE)
hospital_name <- statedata[statedata[,colnum] == min_outcome, 2]
hospital_name <- na.omit(hospital_name)
hospital_name <- sort(hospital_name)
return(hospital_name[1])
}