This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| best <- function(thestate, outcome) { | |
| mydata <- read.csv("outcome-of-care-measures.csv", header = TRUE, sep = ",", | |
| colClasses = "character") | |
| for(i in thestate) { | |
| if(outcome == "heart attack") { | |
| mystate <- subset(mydata, State = thestate, select = c(2, 7, 11)) | |
| ind <- which.min(mystate[, 3]) | |
| myhospital <- mystate[ind, 1] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## find the hospital for state with best heart attack rate | |
| ha <- function(thestate) { | |
| data <- read.csv("outcome-of-care-measures.csv", | |
| header = TRUE, sep = ",", | |
| colClasses = "character") | |
| # convert to proper class | |
| data[,11] <- as.numeric(data[,11]) | |
| for(i in thestate) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| # read in the data | |
| outcome <- read.table("rprog_data_ProgAssignment3-data/outcome-of-care-measures.csv", | |
| header = TRUE, sep = ",", colClasses = "character") | |
| nrow(outcome) | |
| ncol(outcome) | |
| names(outcome) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # problem 1 | |
| # part 1 | |
| pollutantmean <- function(directory, pollutant, id = 1:332) { | |
| filelist <- list.files(path = directory, pattern = ".csv", | |
| full.names = TRUE) | |
| values <- numeric() | |
| for(i in id) { |
NewerOlder