Skip to content

Instantly share code, notes, and snippets.

View ubie79's full-sized avatar

Azhar Ahmad ubie79

  • Universiti Malaysia Pahang
  • Gambang, Kuantan, Pahang, MALAYSIA
View GitHub Profile
@ubie79
ubie79 / best.R
Created May 7, 2020 14:37 — forked from kfeoktistoff/best.R
Programming assignment 3 for Coursera "R Programming" course by Johns Hopkins University
best <- function(state, outcome) {
## Read outcome data
## Check that state and outcome are valid
## Return hospital name in that state with lowest 30-day death
## rate
source("sortHospitalsByOutcome.R")
head(sortHospitalsByOutcome(state, outcome), 1)
}
@ubie79
ubie79 / complete.R
Created May 7, 2020 14:34 — forked from kfeoktistoff/complete.R
The zip file contains 332 comma-separated-value (CSV) files containing pollution monitoring data for fine particulate matter (PM) air pollution at 332 locations in the United States. Each file contains data from a single monitor and the ID number for each monitor is contained in the file name. For example, data for monitor 200 is contained in th…
## Write a function that reads a directory full of files and reports the number of completely observed cases in each data file.
## The function should return a data frame where the first column is the name of the file and the second column is the number
## of complete cases. A prototype of this function follows
complete <- function(directory, id = 1:332) {
## 'directory' is a character vector of length 1 indicating
## the location of the CSV files
## 'id' is an integer vector indicating the monitor ID numbers
## to be used
## Return a data frame of the form: