This file contains 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
hashed_id <- function(x, salt){ | |
y <- paste(x, salt) | |
y <- sapply(y, function(X) digest(X, algo = "sha1")) | |
as.character(y) | |
} | |
data$PseudoID <- hashed_id(data$PseudoID, "somesalt1234") | |
data$Postcode.Sector <- hashed_id(data$Postcode.Sector, "somesalt1234") |
This file contains 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
plt_month <-ggplot(plt_wkd_mean, aes(x = Weekday, y = Average)) | |
plt_month + geom_bar(stat = "identity", position = "identity", alpha = 0.5, width = 0.4, fill= "red") + | |
#geom_line()+ | |
#geom_point()+ | |
scale_y_continuous(expand = c(0, 0), limits = c(0, 200)) + | |
xlim("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") + | |
labs(title = "Chelsea: Montly Occupancy, 1st of Jan to 31st of Dec 2013", | |
subtitle = "Average Occupancy (medical patients) by Days of the Week. | |
Note: results are intended for management information only", | |
y = "Average - Occupancy", x = "Day of the Week", caption = "CLAHRC - NIHR") + #caption = "Source: Imperial Data Dive - Hackaton") + |
This file contains 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) | |
library(lubridate) | |
data <- read.csv("df.csv", header = TRUE) | |
data$X <- NULL | |
####################################################### | |
# Code that converts all the columns names to lowercase |
This file contains 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
################################################### | |
# Arrivals vs Occupancy - ##################### | |
# for one month - from 01-03-2015 to 27-04-2015 ### | |
################################################### | |
################################################## | |
# loading the libraries | |
################################################## | |
library(tidyverse) |
This file contains 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
################################################### | |
# A&E - arrivals - March to April, 27th, 2013 ## | |
################################################### | |
####################### | |
#reading the data ##### | |
####################### | |
data <- read.csv("df.csv", header = TRUE) | |
This file contains 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
############################## | |
# Admissions and Discharges | |
############################## | |
#################### | |
#reading the data ## | |
#################### | |
data <- read.csv("df.csv", header = TRUE) | |
head(data, 10) |
This file contains 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
#################################### | |
# Readmission_7days ################ | |
#################################### | |
library(tidyverse) | |
library(lubridate) | |
data <- read.csv("/df.csv") | |
data$X <- NULL |
This file contains 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
four_hrs_perf_data_clean <- function(df) { | |
colname_ct <- function(df, colname){ | |
df[,colname] = as.POSIXct(df[,colname]) | |
df | |
} | |
df %>% | |
dplyr::select("PAT_CODE", "START_DATETIME", "END_DATETIME", "WARD_CODE", "episode.order", "spell.number") %>% |
This file contains 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
# Creating a new variable out of two | |
data_indices <- df_subs %>% | |
mutate(sex_patient_class = case_when( | |
sex == "Female" & patient.class == "Not_Admitted" ~ "female_not_admitted", | |
sex == "Female" & patient.class == "ORDINARY ADMISSION" ~ "female_admitted", | |
sex == "Male" & patient.class == "Not_Admitted" ~ "male_not_admitted", | |
sex == "Male" & patient.class == "ORDINARY ADMISSION" ~ "male_admitted" | |
)) |
This file contains 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
df_subset <- df %>% | |
filter(spell.type == "Emergency" & sex != "Not Specified", | |
end_datetime >= "2012-09-29" & end_datetime <= "2013-09-29") %>% | |
mutate(as.Date(end_datetime)) %>% | |
replace_na(list(patient.class = "Not_Admitted")) %>% | |
select(pat_code, end_datetime, age_band, sex, patient.class, spell.type) |
OlderNewer