diff --git a/.RData b/.RData new file mode 100644 index 0000000..8eaf402 Binary files /dev/null and b/.RData differ diff --git a/.Rhistory b/.Rhistory new file mode 100644 index 0000000..27a1e19 --- /dev/null +++ b/.Rhistory @@ -0,0 +1,512 @@ +ablineclip(v=7, lty=0,col="sienna2", lwd=2) +ablineclip(v=7, lty=0,col="sienna2", lwd=2) +ablineclip(v=6, lty=6,col="sienna2", lwd=5) +plot(lynx) +plot(lynx,type="p",main="Type p") +plot(lynx,type="l",main="Type l") +plot(lynx,type="b",main="Type b") +plot(lynx,type="c",main="Type c") +plot(lynx,type="o",main="Type o") +plot(lynx,type="h",main="Type h") +plot(lynx,type="s",main="Type s") +plot(lynx,type="n",main="Type n") +par(mar=c(4,3,3,3), color.axis="darkgreen") +par(mar=c(4,3,3,3), col.axis="darkgreen") +par(mar=c(4,3,3,3), col.axis="darkgreen") +plot(cars$speed, type="s", bty="n", xlab="Cars ID", ylab = "") +text(8,14,"Speed in mph", cex=0.85, col = "red") +text(10,14,"Speed in mph", cex=0.85, col = "red") +plot(new=T) +par(new=T) +plot(cars$dist, type="s", bty="n", ann=F, axes=F, col="darkblue") +axis(side=4,col="darkblue") +text(37,18,"Stopping distane in ft",cex=0.85, col="darkblue") +par() +plot(lynx) +plot(lynx,type="p",main="Type p") +plot(lynx,type="l",main="Type l") +plot(lynx,type="b",main="Type b") +plot(lynx,type="c",main="Type c") +plot(lynx,type="o",main="Type o") +plot(lynx,type="h",main="Type h") +plot(lynx,type="s",main="Type s") +plot(lynx,type="n",main="Type n") +plot(x,y) +hist(lynx) +plot(lynx) +?plot +?plot +plot(lynx, main="Title", color = "red", color.main = 52) +plot(lynx, main="Title", col = "red", color.main = 52) +plot(lynx, main="Title", col = "red", color.main = 52) +plot(lynx, main="Title", col = "red", col.main = 52) +plot(lynx, main="Title", col = "red", col.main = 52) +plot(x,y) +plot(lynx, main="Title", col = "red", col.main = 52) +plot(lynx, main="Title", color = "red", col.main = 52) +plot(lynx, main="Title", col = "red", col.main = 52) +plot(lynx, main="Title", col = "red", col.main = 52) +plot(lynx, main="Title", col = "red", col.main = 52, cex.main = 1.5) +plot(lynx, main="Title", col = "red", col.main = 52, cex.main = 3) +plot(lynx, main="Lynx", xlab="Year", ylab="Time", col="red", col.main = 52) +plot(lynx, ylab="Lynx trapping", xlab="",las=2) +plot(lynx, ylab="Lynx trapping", xlab="",las=1) +plot(lynx, ylab="Lynx trapping", xlab="",las=3) +plot(lynx, ylab="Lynx trapping", xlab="",las=0) +plot(lynx, ylab="Lynx trapping", xlab="",las=1) +plot(lynx, ylab="Lynx trapping", xlab="",las=2) +plot(lynx, ylab="Lynx trapping", xlab="",las=2)3par(mfrow=c(2,2), col.axis="red") +plot(lynx, ylab="Lynx trapping", xlab="",las=3) +plot(lynx, mian="Lynx",xlab="Year",ylab = "Time", col = "red", col.main = 52, las = 0) +plot(lynx, mian="Lynx",xlab="Year",ylab = "Time", col = "red", col.main = 52, cex.main = 1, las = 0) +plot(lynx, mian="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1) +plot(lynx, main="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1) +plot(lynx, main="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1) +plot(lynx, main="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1, las = 0) +plot(lynx, main="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1, las = 1) +0 +plot(lynx, main="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1, las = 0) +plot(lynx, main="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1, las = 7) +plot(lynx, main="Lynx",xlab="Year",ylab = "Time", col="red", col.main = 52, cex.main = 1, las = 3) +?par +par(mfrow = c(2,2), col.axis = "red") +plot(1:8, las=0, xlab="xlab", y="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab", y="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +par(mfrow = c(0,0), col.axis = "red") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +par(mfrow = c(0,0), col.axis = "red") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +par(mfrow = c(0,0), col.axis = "red") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +par(mfrow = c(4,4), col.axis = "red") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +par(mfrow = c(4,4), col.axis = "red") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +par(mfrow = c(2,2), col.axis = "red") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +par(mfrow = c(2,2), col.axis = "red") +par(mfrow = c(2,2), col.axis = "red") +plot(1:8, las=0, xlab="xlab",ylab="ylab", main = "LAS = 0") +plot(1:8, las=1, xlab="xlab",ylab="ylab", main = "LAS = 1") +plot(1:8, las=2, xlab="xlab",ylab="ylab", main = "LAS = 2") +plot(1:8, las=3, xlab="xlab",ylab="ylab", main = "LAS = 3") +colors() +?pch +require(stats) # for rnorm +plot(-4:4, -4:4, type = "n") # setting up coord. system +points(rnorm(200), rnorm(200), col = "red") +points(rnorm(100)/2, rnorm(100)/2, col = "blue", cex = 1.5) +x = 2:4 +plot(x, pch=13) +plot(x, pch=25) +plot(x, pch=27) +plot(x, pch='C') +plot(x, pch='A') +par(mfrow = c(1,1), color.axis('red')) +par(mfrow = c(1,1), color.axis('red')) +par(mfrow = c(1,1), color.axis(21)) +par(mfrow = c(1,1), color.axis("red")) +par(mfrow = c(1,1), color.axis="red") +par(mfrow = c(1,1), col.axis="red") +par(mfrow = c(1,1), col.axis="red") +plot(1:7, ylab="",main="Lines", bg = "green") +par(mfrow = c(1,1), col.axis="red") +plot(1:7, ylab="",main="Lines", bg = "green") +plot(1:7, ylab="",main="Lines", bg = "blue") +plot(1:70, ylab="",main="Lines", bg = "blue") +par(mfrow = c(1,1), col.axis="black") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black", bg = "red") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black", bg = "white") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black", bg = "blue") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black", bg = "white") +plot(1:70, ylab="",main="Lines") +par(mfrow = c(1,1), col.axis="black", bg = "white") +x = 2:4 +plot(1:7, ylab = "",main = "Lines", xlab="Lty 0:6") +ablineclip(v=1, lty=1, col = "sienna2", lwd=2) +ablineclip(v=2, lty=2, col = "sienna2", lwd=2) +ablineclip(v=3, lty=3, col = "sienna2", lwd=2) +ablineclip(v=4, lty=4, col = "sienna2", lwd=2) +ablineclip(v=5, lty=5, col = "sienna2", lwd=2) +ablineclip(v=6, lty=6, col = "sienna2", lwd=5) +ablineclip(v=7, lty=0, col = "sienna2", lwd=2) +par(mfrow = c(1,1), col.axis = "red") +plot(lynx,type="p",main="Type p") +plot(lynx,type="l",main="Type l") +plot(lynx,type="b",main="Type b") +plot(lynx,type="c",main="Type c") +plot(lynx,type="o",main="Type o") +plot(lynx,type="h",main="Type h") +plot(lynx,type="s",main="Type s") +plot(lynx,type="n",main="Type n") +?plot +par(mar=c(4,3,3,3), col.axis="darkgreen") +plot(cars$speed, type="s", bty="n", xlab="Cars ID", ylab = "") +text(10,14,"Speed in mph", cex=0.85, col = "red") +par(new=T) +plot(cars$dist, type="s", bty="n", ann=F, axes=F, col="darkblue") +axis(side=4,col="darkblue") +axis(side=2,col="darkblue") +plot(cars$speed, type="s", bty="n", xlab="Cars ID", ylab = "") +text(10,14,"Speed in mph", cex=0.85, col = "red") +par(new=T) +plot(cars$dist, type="s", bty="n", ann=F, axes=F, col="darkblue") +axis(side=2,col="darkblue") +text(37,18,"Stopping distane in ft",cex=0.85, col="darkblue") +par() +plot(cars$speed, type="s", bty="n", xlab="Cars ID", ylab = "") +text(10,14,"Speed in mph", cex=0.85, col = "red") +par(new=T) +plot(cars$dist, type="s", bty="n", ann=F, axes=F, col="darkblue") +axis(side=2,col="darkblue") +text(37,18,"Stopping distane in ft",cex=0.85, col="darkblue") +par() +?plot +help.strt(plot()) +help.start(plot()) +help.start(plot) +help.start('plot') +help.plot +help.start +help.start() +rivers +plot(rivers) +plot(rivers, main = "Length of Major N American rivers") +plot(rivers, main = "Length of Major N American rivers", main.col = 'red') +plot(rivers, main = "Length of Major N American rivers", col.main = 52) +plot(rivers, main = "Length of Major N American rivers", col.main = 'red') +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue') +par(mfrow = c(1,1), col.axis = "black") +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue') +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length in miles") +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length in miles") +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length") +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length in miles", las = 0) +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length in miles", las = 1) +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length in miles") +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length in miles", las = 1) +plot(rivers, main = "Length of Major N American rivers", col.main = 'blue', xlab = "", ylab = "length in miles", las = 0) +?rivers +plot(1:141, rivers) +plot(1:141, rivers, col('green')) +plot(1:141, rivers, col = "green") +plot(1:141, rivers, col = "green", main = "Length of rivers", col.main = "blue") +library(readr) +study_fields <- read_csv("C:/Users/Hammad Ali Khan/Desktop/R/study_fields.csv") +View(study_fields) +?apply +x - matrix(c(1:9), nr-3, byrow = T) +x - matrix(c(1:9), nr-3, byrow = T) +x <- matrix(c(1:9), nr-3, byrow = T) +X - matrix(c(1:9), nr- 3, byrow = T) +X - matrix(c(1:9), nr- 3, byrow - T) +X = matrix(c(1:9), nr= 3, byrow = T) +x +X +apply(X,1,mean) +apply(x,2,mean) +apply(X,2,mean) +apply(x,1,plot) +apply(x,1,plot) +apply(x,1,plot) +apply(X,1,plot) +detach("package:plotrix", unload=TRUE) +install.packages("ggplot2") +library("ggplot2", lib.loc="~/R/win-library/3.3") +Dataset = diamonda +Dataset = diamonds +?diamonds +diamonds +library("ggplot2", lib.loc="~/R/win-library/3.3") +detach("package:ggplot2", unload=TRUE) +library("ggplot2", lib.loc="~/R/win-library/3.3") +detach("package:ggplot2", unload=TRUE) +library("ggplot2", lib.loc="~/R/win-library/3.3") +install.packages("ggplot2") +library("ggplot2", lib.loc="~/R/win-library/3.3") +detach("package:ggplot2", unload=TRUE) +library("ggplot2", lib.loc="~/R/win-library/3.3") +detach("package:ggplot2", unload=TRUE) +library(ggplot2) +library(ggplot2) +??diamonds +diamonds +remove.packages(c("ggplot2", "data.table")) +install.packages('Rcpp', dependencies = TRUE) +install.packages('ggplot2', dependencies = TRUE) +install.packages('data.table', dependencies = TRUE) +remove.packages(c("ggplot2", "data.table")) +install.packages('Rcpp', dependencies = TRUE) +install.packages('ggplot2', dependencies = TRUE) +install.packages('data.table', dependencies = TRUE) +install.packages("Rcpp", dependencies = TRUE) +library("ggplot2", lib.loc="~/R/win-library/3.3") +detach("package:ggplot2", unload=TRUE) +library("ggplot2", lib.loc="~/R/win-library/3.3") +remove.packages(c("ggplot2", "data.table")) +install.packages('Rcpp', dependencies = TRUE) +install.packages("Rcpp", dependencies = TRUE) +install.packages('ggplot2', dependencies = TRUE) +install.packages('data.table', dependencies = TRUE) +library("ggplot2", lib.loc="~/R/win-library/3.3") +detach("package:ggplot2", unload=TRUE) +library("gdtools", lib.loc="~/R/win-library/3.3") +library("ggplot2", lib.loc="~/R/win-library/3.3") +detach("package:ggplot2", unload=TRUE) +library("ggplot2", lib.loc="~/R/win-library/3.3") +install.packages(colorspace) +install.packages('colorspace') +library("ggplot2", lib.loc="~/R/win-library/3.3") +diamonds +summary(diamonds) +dataSet = diamonds +plot(dataSet$depth) +head(diamonds) +attach(diamonds) +qqnorm(depth) +hist(diamonds) +hist(depth) +depthSmall = sample(depth, 5000) +shapiro.test(depthSmall) +install.packages('nortest') +library("nortest", lib.loc="~/R/win-library/3.3") +cvm.test(depth) +lillie.test(depth) +sf.test(depth) +sf.test(depthSmall) +pearson.test(depth) +diamonds +?histrogram +??histrogram +library("ggplot2", lib.loc="~/R/win-library/3.3") +install.packages("lattice") +library("lattice", lib.loc="~/R/win-library/3.3") +library("lattice", lib.loc="C:/Program Files/R/R-3.3.3/library") +detach("package:lattice", unload=TRUE) +library("lattice", lib.loc="~/R/win-library/3.3") +iris +?histogram +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 1, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 1, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 4, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 0.5, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 0.1, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 0.3, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(1,4), aspect = 0.3, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(4,4), aspect = 0.3, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 17, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 0.3, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 10, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 0.3, +xlab = "Height (inches)") +histogram( ~ height | voice.part, data = singer, nint = 4, +endpoints = c(59.5, 76.5), layout = c(2,4), aspect = 0.3, +xlab = "Height (inches)") +install.packages('swirl') +swirl() +library(swirl) +install_course('Getting and Cleaning Data') +install_course('Getting and Cleaning Data') +install_course('Getting and Cleaning Data') +library(swirl) +install_course('Getting and Cleaning Data') +swirl() +mydf <- read.csv(path2csv, stringsAsFactors = F) +mydf <- read.csv(path2csv, stringsAsFactors = FALSE) +dim(mydf) +head(mydf) +library(dplyr) +packageVersion("dplyr") +cran <- tbl_df(mydf) +rm("mydf") +?tbl_df +tbl_df +cran +>select() +?select +select(cran, ip_id, package, country) +5:20 +select(cran , r_arch:country) +select(cran, country:r_arch) +cran +select(cran, -time) +-5:20 +-(5:20) +select(cran, -(X:size)) +filter(cran, package == "swirl") +filter(cran, r_version == "3.1.1", country == "US") +?Comparison +filter(cran, r_version <= "3.0.2", country == "US") +filter(cran, r_version <= "3.0.2", country == "IN") +filter(cran, country == "US" | country == "IN") +filter(cran, size > 100500, r_os == "linux-gnu") +is.na()c(3,5,NA,10) +is.na(c(3,5,NA,10)) +!is.na(c(3,5,NA,10)) +R.version +r_version +filter(cran, !is.na(r_version)) +cran2 <- select(cran, size:ip_id) +arrange(cran2, asc(ip_id) +) +arrange(cran2, asc(ip_id)) +arrange(cran2, ip_id) +arrange(cran2, desc(ip_id) +arrange(cran2, desc(ip_id)) +arrange(cran2, desc(ip_id)) +arrange(cran2, package, ip_id) +arrange(cran2, ip_id) +arrange(cran2, country, desc(r_version), ip_id) +cran3 <- select(cran, ip_id,package, size) +cran3 +mutate(cran3, size_mb = size / 2^20) +mutate(cran3, size_mb = size / 2^20, size_gb = size_mb / 2^10) +mutate(cran3, correct_size = size + 1000) +summarize(cran, avg_bytes = mean(size)) +libray(dplyr) +library(dplyr) +cran <- tbl_df(mydf) +rm("mydf") +cran +?group_by +by_package <- group_by(cran, package) +by_package +summarize(by_package, mean(size)) +submit() +pack_sum +quantile(pack_sum$count, probs = 0.99) +top_counts <- filter(pack_sum, count > 679) +top_counts +View(top_counts) +top_counts_sorted <- arrange(top_counts, desc(count) +) +View(top_counts_sorted) +quantile(pack_sum$unique, probs = 0.99) +pack_sum +top_unique <- filter(pack_sum, unique > 465) +View(top_unique) +top_unique_sorted <- arrange(top_unique, desc(unique)) +View(top_unique_sorted) +submit() +submit() +submit() +View(result3) +submit() +submit() +submit() +reset() +submit() +submit() +swirl() +submit() +submit() +submit() +submit() +submit() +submit() +library(tidyr) +students +?gather +gather(students,sex,count,-grade) +students2 +?gather() +students2 +gather(students2, sex_class, count, -grade) +res <- gather(students2, sex_class, count, -grade) +res +?seperate() +?separate +separate(data = res, col = sex_class, into = c('sex','class')) +submit() +submit() +submit() +students3 +submit() +submit() +?chain +submit() +submit() +submit() +submit() +?gather +submit() +students3 +submit() +submit() +submit() +?spread +submit() +submit() +submit() +setwd("C:/Users/Hammad Ali Khan/Desktop/hammad_khi_assignment2") +library(lubridate) +bufferedDataFrame <- read.csv("hospitaldata.csv", strip.white = T, na.strings = c("-",""," ","\t","\n",NA), stringsAsFactors = F) +df <- tbl_df(bufferedDataFrame) +names(df) <- gsub("\\.", "", names(df)) +df$Age <- as.numeric(gsub("[^0-9]",'',df$Age)) +df$Date <- as.Date(strptime(df$Date, "%a, %B %d, %Y")) +df$Time <- format(strptime(df$Time, format='%I:%M %p'), '%I:%M %p') +df$Sex <- toupper(df$Sex) +df$TotalCharges <- as.numeric(gsub("cancelled", NA, ignore.case = T,df$TotalCharges)) +df$Procedure <- (gsub("cancelled", NA, ignore.case = T,df$Procedure)) +library(dplyr) +library(lubridate) +library(tidyr) +bufferedDataFrame <- read.csv("hospitaldata.csv", strip.white = T, na.strings = c("-",""," ","\t","\n",NA), stringsAsFactors = F) +df <- tbl_df(bufferedDataFrame) +names(df) <- gsub("\\.", "", names(df)) +df$Age <- as.numeric(gsub("[^0-9]",'',df$Age)) +df$Date <- as.Date(strptime(df$Date, "%a, %B %d, %Y")) +df$Time <- format(strptime(df$Time, format='%I:%M %p'), '%I:%M %p') +df$Sex <- toupper(df$Sex) +df$TotalCharges <- as.numeric(gsub("cancelled", NA, ignore.case = T,df$TotalCharges)) +df$Procedure <- (gsub("cancelled", NA, ignore.case = T,df$Procedure)) +df$AmountBalance <- as.numeric(gsub(",",'',df$AmountBalance)) +high_time_repeated <- df %>% +filter(!is.na(Time)) %>% +group_by(Time) %>% +tally() %>% +View() +high_time_repeated <- df %>% +filter(!is.na(Time)) %>% +group_by(Time) %>% +tally() %>% +arrange(desc(n)) +View(high_time_repeated) +high_time_repeated$Time[high_time_repeated$n == max(high_time_repeated$n)] diff --git a/CleanHospitalData.csv b/CleanHospitalData.csv new file mode 100644 index 0000000..a47df0c --- /dev/null +++ b/CleanHospitalData.csv @@ -0,0 +1,223 @@ +"","Date","id","Time","Age","Sex","ConsultingDoctor","Specialty","Procedure","TotalCharges","AmountReceived","AmountBalance","AmountReceivedBy","AmountinHospital","ReceptionistName","NextApt" +"1",2017-01-01,101,"11:00 AM",40,"F","Dr Kinza Alam","Gynae","C Section",30000,30000,NA,"Mrs Shamsa",NA,"Hamza",NA +"2",2017-01-02,150,"10:45 AM",26,"M","Nursing Staff",NA,"Dressing",1500,1500,NA,"Dr Saniya",NA,"Haris",NA +"3",2017-01-02,58,"12:38 PM",30,"F","Dr Riffat Naheed","Psychotherapist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Fiza",NA +"4",2017-01-02,75,"01:00 PM",40,"M","Dr Riffat Naheed","Psychotherapist","Consultation",1500,1500,NA,"Mrs Shamsa",450,"Zaheer",NA +"5",2017-01-02,97,"02:45 PM",27,"M","Dr Riffat Naheed","Psychotherapist","Consultation",2000,2000,NA,"Mrs Shamsa",600,"Haris",NA +"6",2017-01-02,101,"03:00 PM",40,"F","Dr Kinza Alam","Gynae","C Section",35000,35000,NA,"Dr Saniya",NA,"Haris",NA +"7",2017-01-02,26,"03:28 PM",43,"M","Dr Saniya","M/o","Consultation",2000,2000,NA,"Dr Saniya",NA,"Fiza",NA +"8",2017-01-02,149,"03:45 PM",28,"F","Dr Fakiha","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Haris",NA +"9",2017-01-02,20,"03:45 PM",2,"F","Dr Fakiha","Dentist","Consultation",NA,NA,NA,NA,NA,NA,NA +"10",2017-01-02,72,"05:00 PM",40,"M","Dr Fakiha","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Fiza",NA +"11",2017-01-02,54,"05:00 PM",32,"F","Dr Saniya","M/o","Consultation",2000,2000,NA,"Dr Saniya",NA,"Fiza",NA +"12",2017-01-02,149,"05:30 PM",28,"F","Dr Fakiha","Dentist","Filling",2000,2000,NA,"Mrs Shamsa",2000,"Fiza","In case of pain" +"13",2017-01-03,120,"01:00 PM",76,"F","Dr Saniya","M/o","Laboratory Test",NA,NA,NA,NA,NA,"Haris",NA +"14",2017-01-03,120,"03:25 PM",75,"F","Dr Saniya","M/o",NA,NA,NA,NA,NA,NA,NA,NA +"15",2017-01-03,20,"06:10 PM",36,"F","Dr Kinza Alam","Gynae","Consultation",1500,1500,NA,"Mrs Shamsa",450,"Haris",NA +"16",2017-01-04,40,"11:45 PM",42,"F","Dr Alaf Khan","Dentist","Consultation+Denture",1500,1500,NA,"Brig Farrukh",NA,"Fiza",NA +"17",2017-01-04,134,"12:40 PM",23,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Brig Farrukh",500,"Fiza",NA +"18",2017-01-04,86,"08:10 PM",48,"F","Dr Kinza Alam","Gynae","Consultation",1500,1500,NA,"Brig Farrukh",450,"Haris",NA +"19",2017-01-04,114,"08:30 PM",25,"F","Dr Kinza Alam","Gynae","Consultation",1000,1000,NA,"Brig Farrukh",300,"Haris",NA +"20",2017-01-05,155,"12:40 PM",50,"F","Dr Alaf Khan","Dentist","Extraction",2000,2000,NA,"Brig Farrukh",2000,"Fiza",NA +"21",2017-01-05,45,"02:00 PM",60,"F","Dr Alaf Khan","Dentist","R.P.D + Crown",4000,4000,NA,"Brig Farrukh",4000,"Haris",NA +"22",2017-01-05,4,"02:00 PM",NA,"M","Dr Irfan","General Surgeon","Consultation + Dressing",5000,5000,NA,"Brig Farrukh",4000,"Haris",NA +"23",2017-01-06,38,"12:30 PM",NA,"M","Dr Riffat Naheed","Psychotherapist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Haris",NA +"24",2017-01-06,130,"01:00 PM",26,"M","Dr Riffat Naheed","Psychotherapist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Haris",NA +"25",2017-01-06,97,"01:30 PM",27,"M","Dr Riffat Naheed","Psychotherapist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Haris",NA +"26",2017-01-06,50,NA,NA,"M","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Haris",NA +"27",2017-01-06,78,"08:15 PM",57,"F","Dr Ali","Orthopedic","Consultation",6000,6000,NA,"Mrs Shamsa",3000,"Haris",NA +"28",2017-01-07,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"29",2017-01-09,48,"12:36 PM",39,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Fiza",NA +"30",2017-01-09,79,"01:30 PM",6,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Fiza",NA +"31",2017-01-09,116,"02:30 PM",26,"M","Dr Alaf Khan","Dentist","X Ray",300,300,NA,"Mrs Shamsa",300,"Haris",NA +"32",2017-01-09,45,"03:15 PM",60,"F","Dr Alaf Khan","Dentist","R.P.D + Crown",7000,7000,NA,"Mrs Shamsa",7000,"Fiza",NA +"33",2017-01-09,67,"05:20 PM",26,"M","Dr Alaf Khan","Dentist","Consultation+X Ray",800,800,NA,"Mrs Shamsa",800,"Fiza",NA +"34",2017-01-09,36,"05:30 PM",5,"F","Dr Alaf Khan","Dentist","Consultation",250,250,NA,"Mrs Shamsa",250,"Fiza",NA +"35",2017-01-10,17,"03:50 PM",40,"M","Dr Alaf Khan","Dentist","RCT (4 teeth) Bridge (9 teeth)",10000,10000,NA,"Mrs Shamsa",NA,"Fiza","1/16/2017" +"36",2017-01-10,84,"06:00 PM",9,"F","Dr Irfan","General Surgeon","Consultation + X Ray",3000,3000,NA,"Mrs Shamsa",3000,"Mona",NA +"37",2017-01-10,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"38",2017-01-11,57,NA,30,"F","Dr Alaf Khan","Dentist","Laboratory Test",NA,NA,NA,"Mrs Shamsa",NA,NA,NA +"39",2017-01-11,119,"03:00 PM",40,"F","Dr Ammara","Gynae","Consultation + USG",1500,1500,NA,"Mrs Shamsa",500,"Fiza",NA +"40",2017-01-11,145,"04:30 PM",29,"M","Dr Alaf Khan","Dentist","Crown",3000,3000,NA,"Mrs Shamsa",NA,"Fiza",NA +"41",2017-01-11,92,"04:30 PM",39,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Fiza",NA +"42",2017-01-12,63,"10:45 AM",50,"M","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Fiza",NA +"43",2017-01-12,63,"02:00 PM",50,"M","Dr Alaf Khan","Dentist","Scalling",3000,3000,NA,"Mrs Shamsa",3000,"Fiza",NA +"44",2017-01-12,63,"02:00 PM",50,"M","Brig Asif","Medical Specialist","Consultation",500,500,NA,"Mrs Shamsa",150,"Fiza",NA +"45",2017-01-13,45,"11:20 AM",60,"F","Dr Alaf Khan","Dentist","Polishing",500,500,NA,"Mrs Shamsa",500,"Haris",NA +"46",2017-01-13,145,"03:00 PM",29,"M","Dr Fakiha","Dentist","Crown",1500,1500,NA,"Mrs Shamsa",1500,"Fiza",NA +"47",2017-01-13,70,"08:00 PM",48,"M","Brig Farrukh","Anaesthetist","Consultation",3750,3750,NA,"Dr Ammad",3750,"Mona",NA +"48",2017-01-14,88,"04:30 PM",45,"F","Dr Fakiha","Dentist","Filling + X Rays",2600,2600,NA,"Dr Ammad",2600,"Haris",NA +"49",2017-01-14,40,"06:30 PM",42,"F","Dr Fakiha","Dentist","Denture+Scalling+Filling",5500,5500,NA,"Dr Ammad",5500,"Haris",NA +"50",2017-01-15,42,"09:00 PM",29,"F","Nursing Staff",NA,"Pharmacy",900,900,NA,"Dilshad",900,"Zaheer",NA +"51",2017-01-16,7,NA,26,"M","Nursing Staff",NA,"Laboratory Test",NA,NA,NA,NA,NA,NA,NA +"52",2017-01-16,106,"01:30 PM",34,"M","Dr Alaf Khan","Dentist","Crown",5000,5000,NA,"Dr Ammad",5000,"Fiza",NA +"53",2017-01-16,22,"06:00 PM",50,"F","Dr Zubair","M/o","Consultation",1000,1000,NA,"Dr Ammad",400,"Haris",NA +"54",2017-01-16,88,"06:20 PM",45,"F","Dr Fakiha","Dentist","Extraction",2500,2500,NA,"Dr Ammad",2500,"Haris","1/23/2017" +"55",2017-01-17,52,"11:25 AM",30,"M","Dr Alaf Khan","Dentist","RCT",3000,3000,NA,"Mrs Shamsa",3000,"Fiza","1/20/2017" +"56",2017-01-17,17,"11:15 AM",40,"M","Dr Alaf Khan","Dentist","RCT (4 teeth) Bridge (9 teeth)",38000,38000,NA,"Mrs Shamsa",38000,"Fiza",NA +"57",2017-01-17,17,"01:10 PM",40,"M","Brig Asif","Medical Specialist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Haris",NA +"58",2017-01-17,136,"03:30 PM",29,"M","Dr Fakiha","Dentist","Scalling",4000,4000,NA,"Mrs Shamsa",4000,"Fiza",NA +"59",2017-01-17,27,"06:15 PM",27,"M","Dr Fakiha","Dentist","Filling",2000,2000,NA,"Mrs Shamsa",2000,"Sohaib","1/19/2017" +"60",2017-01-18,71,"09:40 PM",23,"M","Dr Alaf Khan","Dentist","X Ray",300,300,NA,NA,300,"Haris",NA +"61",2017-01-18,12,"12:00 PM",60,"F","Dr Alaf Khan","Dentist","22 Unit Bridge",25500,25500,NA,NA,25500,"Haris",NA +"62",2017-01-18,127,"02:00 PM",52,"F","Dr Alaf Khan","Dentist","Extraction",1000,1000,NA,NA,1000,"Haris",NA +"63",2017-01-18,82,"05:00 PM",21,"M","Dr Zubair","M/o","Consultation",500,500,NA,NA,500,"Haris",NA +"64",2017-01-19,103,NA,32,"M","Nursing Staff",NA,"Laboratory Test",NA,NA,NA,NA,NA,NA,NA +"65",2017-01-19,31,"11:00 AM",58,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Mrs Shamsa",500,"Haris",NA +"66",2017-01-19,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"67",2017-01-19,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"68",2017-01-20,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"69",2017-01-21,131,"10:15 AM",26,"F","Dr Alaf Khan","Dentist","X Ray",300,300,NA,"Mrs Shamsa",300,"Haris",NA +"70",2017-01-21,101,"01:20 PM",40,"F","Dr Kinza Alam","Gynae","Consultation",1200,1200,NA,"Mrs Shamsa",360,"Haris",NA +"71",2017-01-21,145,"01:30 PM",29,"M","Dr Fakiha","Dentist","Crown",500,500,NA,"Mrs Shamsa",500,"Haris",NA +"72",2017-01-23,144,"12:15 PM",33,"M","Dr Riffat Naheed","Psychotherapist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Haris",NA +"73",2017-01-23,37,"01:00 PM",30,"F","Dr Riffat Naheed","Psychotherapist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Haris",NA +"74",2017-01-23,135,"01:15 PM",28,"F","Dr Riffat Naheed","Psychotherapist","Consultation",2000,2000,NA,"Mrs Shamsa",600,"Haris",NA +"75",2017-01-23,59,"04:50 PM",10,"M","Dr Ali","Child Specialist","Consultation+ER Retain",2800,2800,NA,"Mrs Shamsa",1600,"Haris",NA +"76",2017-01-24,130,"01:00 PM",26,"M","Dr Riffat Naheed","Psychotherapist","Consultation",800,800,NA,"Mrs Shamsa",240,"Haris",NA +"77",2017-01-24,104,"01:15 PM",19,"M","Dr Riffat Naheed","Psychotherapist","Consultation",2000,2000,NA,"Mrs Shamsa",600,"Haris",NA +"78",2017-01-24,98,"02:10 PM",53,"F","Dr Saad","Orthopedic","Consultation",1000,1000,NA,"Mrs Shamsa",600,"Haris",NA +"79",2017-01-24,102,"01:30 PM",30,"M","Dr Riffat Naheed","Psychotherapist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Haris",NA +"80",2017-01-25,59,NA,10,"M","Nursing Staff",NA,"Laboratory Test",NA,NA,NA,NA,NA,NA,NA +"81",2017-01-25,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"82",2017-01-26,73,"12:50 PM",55,"M","Dr Alaf Khan","Dentist","Consultation+X Ray",700,700,NA,NA,700,"Haris",NA +"83",2017-01-26,116,"03:30 PM",26,"M","Dr Alaf Khan","Dentist","X Ray",300,300,NA,NA,300,"Haris",NA +"84",2017-01-26,125,"05:40 PM",30,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,NA,500,"Haris",NA +"85",2017-01-26,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"86",2017-01-26,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"87",2017-01-26,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"88",2017-01-28,129,NA,28,"M","Dr Ali","Child Specialist","Consultation",1150,1150,NA,"Mrs Shamsa",NA,"Sohaib",NA +"89",2017-01-28,85,"06:45 PM",NA,"F","Dr Irfan","General Surgeon",NA,3000,3000,NA,"Mrs Shamsa",NA,"Sohaib",NA +"90",2017-01-28,147,"09:45 PM",9,"M","Nursing Staff",NA,"Consultation",1000,1000,NA,"Mrs Shamsa",NA,"Sub KB",NA +"91",2017-01-29,1,NA,NA,NA,"Nursing Staff",NA,"Pharmacy",NA,NA,NA,NA,NA,NA,NA +"92",2017-01-30,140,"01:00 PM",28,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"93",2017-01-30,39,"01:30 PM",47,"M","Dr Alaf Khan","Dentist","X Ray",300,300,NA,"Dr Ammad",300,"Haris",NA +"94",2017-01-30,124,"05:40 PM",49,"F","Brig Asif","Medical Specialist","Consultation+ECG",1300,1300,NA,"Dr Ammad",600,"Sohaib",NA +"95",2017-01-30,8,"05:35 PM",19,"M","Dr Qurat ul Ain","Dentist","Consultation+X Ray",800,800,NA,"Dr Ammad",800,"Sohaib",NA +"96",2017-01-30,51,"06:00 PM",31,"M","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Sohaib",NA +"97",2017-01-31,152,"05:30 PM",7,"F","Dr Fakiha","Dentist","Filling",1000,1000,NA,"Mrs Shamsa",1000,"Haris",NA +"98",2017-01-31,21,"06:30 PM",26,"M","Dr Zubair","M/o","Consultation",200,200,NA,"Mrs Shamsa",200,"Mona",NA +"99",2017-01-31,115,"06:50 PM",8,"F","Dr Qurat ul Ain","Dentist","Extraction",1500,1500,NA,"Mrs Shamsa",1500,"Haris",NA +"100",2017-02-01,109,"02:10 PM",28,"F","Dr Alaf Khan","Dentist","R.C.T",2000,2000,NA,"Dr Ammad",2000,"Haris","2/6/2017" +"101",2017-02-01,153,"02:10 PM",17,"F","Dr Alaf Khan","Dentist","Orthodontics",10000,10000,NA,"Dr Ammad",10000,"Haris","2/6/2017" +"102",2017-02-01,62,"01:00 PM",54,"M","Dr Alaf Khan","Dentist","Scalling",2000,2000,NA,"Dr Ammad",2000,"Haris",NA +"103",2017-02-01,111,"01:40 PM",35,"F","Col Ulfat Ellahi","ENT","Consultation",1000,1000,NA,"Dr Ammad",300,"Haris",NA +"104",2017-02-01,142,"06:00 PM",45,"M","Dr Qurat ul Ain","Dentist","Extraction",2000,2000,NA,"Dr Ammad",2000,"Haris",NA +"105",2017-02-02,117,"12:00 PM",30,"F","Dr Shireen","M/o","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"106",2017-02-02,140,"01:00 PM",30,"F","Dr Alaf Khan","Dentist","Extraction",1000,1000,NA,"Dr Ammad",1000,"Haris",NA +"107",2017-02-02,100,"01:25 PM",23,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"108",2017-02-03,133,"04:45 PM",27,"F","Dr Alaf Khan","Dentist","X Ray",500,500,NA,"Dr Ammad",500,"Haris",NA +"109",2017-02-03,44,"08:00 PM",6,"M","Dr Ali","Child Specialist","Consultation",1000,1000,NA,"Dr Ammad",300,"Haris",NA +"110",2017-02-04,35,"04:00 PM",2,"F","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"111",2017-02-04,150,"04:00 PM",30,"M","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"112",2017-02-06,118,"07:30 PM",32,"F","Dr Kinza Alam","Gynae","Consultation+USG",1500,1500,NA,"Dr Ammad",800,"Haris",NA +"113",2017-02-06,114,"07:45 PM",25,"F","Dr Kinza Alam","Gynae","Consultation",1000,1000,NA,"Dr Ammad",300,"Haris",NA +"114",2017-02-06,49,"01:30 PM",80,"M","Dr Ali","Child Specialist","Consultation+Retain",3500,3500,NA,"Dr Ammad",2000,"Haris",NA +"115",2017-02-06,126,"01:30 PM",70,"F","Dr Alaf Khan","Dentist","Scalling",3000,3000,NA,"Dr Ammad",3000,"Haris",NA +"116",2017-02-06,141,"04:00 PM",20,"M","Dr Riffat Naheed","Psychotherapist","Consultation",2000,2000,NA,"Dr Ammad",600,"Haris",NA +"117",2017-02-06,17,"06:15 PM",23,"M","Dr Ammad","M/o","Consultation",200,200,NA,"Dr Ammad",200,"Haris",NA +"118",2017-02-07,12,"12:00 PM",60,"F","Dr Alaf Khan","Dentist","22 Unit Bridge",44000,30000,14000,"Dr Ammad",30000,"Haris","2/14/2017" +"119",2017-02-07,60,"01:10 PM",50,"M","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"120",2017-02-07,140,"02:15 PM",30,"F","Dr Alaf Khan","Dentist","4 Unit Bridge",3000,3000,NA,"Dr Ammad",3000,"Haris",NA +"121",2017-02-07,41,"06:00 PM",13,"M","Dr Qurat ul Ain","Dentist","X Ray",500,500,NA,"Dr Ammad",500,"Haris",NA +"122",2017-02-07,87,"08:00 PM",30,"F","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"123",2017-02-08,132,"10:13 AM",13,"M","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris","2/17/2017" +"124",2017-02-08,132,"12:00 PM",13,"M","Dr Alaf Khan","Dentist","R.C.T",3500,3500,NA,"Dr Ammad",3500,"Haris",NA +"125",2017-02-08,13,"12:00 PM",39,"F","Dr Saad","Orthopedic","Consultation",1000,1000,NA,"Dr Ammad",300,"Haris",NA +"126",2017-02-08,109,"02:40 PM",28,"F","Dr Alaf Khan","Dentist","R.C.T",2000,2000,NA,"Dr Ammad",2000,"Haris",NA +"127",2017-02-08,109,"02:40 PM",28,"F","Dr Alaf Khan","Dentist","Crown",3000,NA,3000,"Dr Ammad",NA,"Haris","2/16/2017" +"128",2017-02-08,153,"02:40 PM",17,"F","Dr Alaf Khan","Dentist","Orthodontics",110000,20000,90000,"Dr Ammad",20000,"Haris","2/16/2017" +"129",2017-02-08,43,"10:00 AM",27,"M","Dr Alaf Khan","Dentist","Consultation+X Ray",800,800,NA,"Dr Ammad",800,"Haris","2/9/2017" +"130",2017-02-10,5,"09:30 AM",57,"M","Dr Alaf Khan","Dentist","X Ray",300,300,NA,"Dr Ammad",300,"Haris",NA +"131",2017-02-10,14,"06:30 PM",6,"M","Nursing Staff",NA,"X Ray",300,300,NA,"Dr Ammad",300,"Haris",NA +"132",2017-02-10,123,"07:00 PM",18,"M","Dr Qurat ul Ain","Dentist","Filling",1500,1500,NA,"Dr Ammad",1500,"Haris",NA +"133",2017-02-11,137,"12:00 PM",25,"M","Dr Ali","Child Specialist","Consultation",1000,1000,NA,"Mrs Shamsa",300,"Mona",NA +"134",2017-02-11,91,"04:20 PM",50,"F","Dr Qurat ul Ain","Dentist","Scalling",2500,2500,NA,"Mrs Shamsa",2500,"Mona",NA +"135",2017-02-11,23,"05:57 PM",NA,"F","Dr Qurat ul Ain","Dentist","Consultation",1000,1000,NA,"Mrs Shamsa",1000,"Mona",NA +"136",2017-02-11,154,"06:15 PM",19,"F","Dr Qurat ul Ain","Dentist","Scalling",2000,2000,NA,"Mrs Shamsa",2000,"Mona",NA +"137",2017-02-12,112,"07:15 PM",39,"M","Dr Saad","Orthopedic","Operation",35000,35000,NA,"Mrs Shamsa",35000,"Haris",NA +"138",2017-02-12,81,"12:00 PM",6,"F","Dr Alaf Khan","Dentist","Consultation+X Ray",700,700,NA,"Mrs Shamsa",700,"Mona",NA +"139",2017-02-13,15,"11:20 AM",40,"M","Dr Waqar Azeem","Radiologist","USG Abdomen",1000,1000,NA,"Dr Ammad",300,"Haris",NA +"140",2017-02-13,112,"03:40 PM",39,"M","Dr Saad","Orthopedic","Operation",15000,15000,NA,"Dr Ammad",15000,"Haris",NA +"141",2017-02-13,9,"07:00 PM",20,"F","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Haris",NA +"142",2017-02-13,2,NA,NA,NA,"Dr Ali","Child Specialist","Consultation",1500,1500,NA,"Dr Ammad",500,"Haris",NA +"143",2017-02-14,113,"02:30 PM",14,"M","Dr Saad Riaz","Orthopedic","Pop",3700,3700,NA,"Dr Ammad",1700,"Haris",NA +"144",2017-02-14,4,"03:00 PM",NA,"M","Nursing Staff",NA,"Er Retain",300,300,NA,"Dr Ammad",300,"Haris",NA +"145",2017-02-14,19,"07:02 PM",6,"F","Dr Waqar Azeem","Radiologist","USG",2000,2000,NA,"Dr Ammad",1300,"Haris",NA +"146",2017-02-15,118,"11:40 AM",24,"F","Dr Alaf Khan","Dentist","X Ray",400,400,NA,"Mrs Shamsa",400,"Mona",NA +"147",2017-02-15,94,"04:45 PM",3,"M","Dr Ali","Child Specialist","Consultation + Nebulize",1150,1150,NA," 150 Mrs Shamsa, 300 Dr Ammad ",450,"Haris",NA +"148",2017-02-15,64,"06:15 PM",23,"M","Dr Ammad","M/o","Consultation",200,200,NA,"Dr Ammad",200,"Haris",NA +"149",2017-02-17,29,"04:10 PM",29,"M","Dr Alaf Khan","Dentist","X Ray",200,200,NA,"Dr Ammad",200,"Haris",NA +"150",2017-02-17,66,"05:30 PM",55,"M","Dr Alaf Khan","Dentist","Extraction",1000,1000,NA,"Dr Ammad",1000,"Haris",NA +"151",2017-02-17,107,"06:30 PM",30,"F","Nursing Staff",NA,"X Ray",1000,1000,NA,"Dr Ammad",1000,"Haris",NA +"152",2017-02-18,108,"06:20 PM",NA,"M","Dr Ali","Child Specialist","Consultation",3000,3000,NA,"Dr Ammad",1600,"Saima",NA +"153",2017-02-18,30,"06:10 PM",30,"F","Dr Qurat ul Ain","Dentist","Extraction",1500,1500,NA,"Dr Ammad",1500,"Mona",NA +"154",2017-02-18,94,"11:30 AM",3,"M","Nursing Staff",NA,"Injection",300,300,NA,"Dr Ammad",300,"Saima",NA +"155",2017-02-19,55,"02:45 PM",NA,"M","Dr Qurat ul Ain","Dentist","X Ray",300,300,NA,"Dr Ammad",300,"Saima",NA +"156",2017-02-20,132,NA,13,"M","Dr Alaf Khan","Dentist","Crown",5000,5000,NA,"Dr Ammad",5000,NA,"2/24/2017" +"157",2017-02-20,68,"01:25 PM",10,"M","Dr Shireen","M/o","Stiches",700,700,NA,"Dr Ammad",700,"Saima",NA +"158",2017-02-20,80,"02:00 PM",30,"F","Dr Shireen","M/o","Consultation",1200,1200,NA,"Dr Ammad",1200,"Saima",NA +"159",2017-02-20,99,"07:00 PM",45,"F","Dr Saima Shams","Radiologist","USG",1500,1500,NA,"Dr Ammad",900,"Mona",NA +"160",2017-02-20,94,"10:15 PM",3,"M","Nursing Staff",NA,"Injection",300,300,NA,"Dr Ammad",300,"Ashfaq",NA +"161",2017-02-21,151,"01:00 PM",38,"M","Dr Alaf Khan","Dentist","R.C.T+Scalling+Crown",5000,5000,NA,"Dr Ammad",5000,"Saima","2/28/2017" +"162",2017-02-21,53,"06:00 PM",20,"F","Dr Waqar Azeem","Radiologist","USG",1000,1000,NA,"Dr Ammad",400,"Mona",NA +"163",2017-02-21,11,"07:11 PM",2,"F","Dr Ali","Child Specialist","Consultation",1000,1000,NA,"Dr Ammad",300,"Saima",NA +"164",2017-02-21,94,"10:10 PM",3,"M","Nursing Staff",NA,"Injection",300,300,NA,"Dr Ammad",300,"Sub KB",NA +"165",2017-02-21,64,NA,NA,NA,"Nursing Staff",NA,"Medicine",100,100,NA,NA,100,"Saima",NA +"166",2017-02-22,100,"03:00 PM",23,"F","Dr Alaf Khan","Dentist","Orthodontics",120000,30000,90000,"Dr Ammad",30000,"Mona",NA +"167",2017-02-22,16,"04:30 PM",26,"M","Dr Mumtaz","General Surgeon","Consultation",1000,1000,NA,"Dr Ammad",500,"Mona",NA +"168",2017-02-22,6,"05:00 PM",35,"M","Dr Waqar Azeem","Radiologist","USG",1000,1000,NA,"Dr Ammad",400,"Mona",NA +"169",2017-02-23,33,"01:55 PM",22,"M","Dr Alaf Khan","Dentist","R.C.T",3000,3000,NA,"Dr Ammad",3000,"Saima",NA +"170",2017-02-23,89,"01:50 PM",65,"F","Dr Saad Riaz","Orthopedic","Consultation",1000,1000,NA,"Dr Ammad",500,"Saima",NA +"171",2017-02-23,13,"02:00 PM",45,"F","Dr Saad Riaz","Orthopedic","Consultation",1000,1000,NA,"Dr Ammad",300,"Saima",NA +"172",2017-02-23,47,"03:00 PM",21,"F","Dr Riffat Naheed","Psychotherapist","Consultation",1500,1500,NA,"Dr Ammad",700,"Saima",NA +"173",2017-02-24,80,"09:30 PM",30,"F","Dr Mehwish","Gynae","Consultation",1000,1000,NA,"Dr Ammad",500,"Saima",NA +"174",2017-02-25,128,"03:45 PM",64,"F","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"175",2017-02-25,93,"04:00 PM",40,"F","Dr Ali","Child Specialist",NA,3000,3000,NA,"Dr Ammad",1600,"Saima",NA +"176",2017-02-27,143,"11:30 AM",52,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"177",2017-02-27,56,"12:20 PM",55,"F","Dr Alaf Khan","Dentist","Extraction",600,600,NA,"Dr Ammad",600,"Saima",NA +"178",2017-02-27,96,NA,54,"M","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"179",2017-02-28,65,"10:30 PM",30,"M","Nursing Staff",NA,"BSR",50,50,NA,"Dr Ammad",50,"Haris",NA +"180",2017-02-28,96,"12:40 PM",53,"M","Dr Alaf Khan","Dentist","8 Unit Bridge+2 R.C.T",30000,8000,22000,"Dr Ammad",8000,"Haris",NA +"181",2017-02-28,90,NA,NA,"F","Dr Alaf Khan","Dental","Consultation",1000,1000,NA,"Dr Ammad",1000,"Saima",NA +"182",2017-02-28,151,"03:00 PM",38,"F","Dr Alaf Khan","Dentist","R.C.T+Scalling+Crown",4500,4500,NA,"Dr Ammad",4500,"Haris",NA +"183",2017-02-28,139,"08:00 PM",30,"M","Nursing Staff",NA,"X Ray",500,500,NA,"Dr Ammad",500,"Saima",NA +"184",2017-03-01,107,"05:00 PM",17,"F","Dr Qurat ul Ain","Dentist","Extraction",1500,1500,NA,"Dr Ammad",1500,"Saima",NA +"185",2017-03-01,28,"06:00 PM",3,"F","Dr Qurat ul Ain","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"186",2017-03-01,46,NA,17,"M","Nursing Staff",NA,"Dressing",500,500,NA,"Dr Ammad",200,"Saima",NA +"187",2017-03-01,25,"07:00 PM",NA,"F","Dr Kinza Alam","Gynae","Consultation",1500,1500,NA,"Dr Ammad",500,"Saima",NA +"188",2017-03-01,24,"07:10 PM",NA,"M","Dr Ammad","M/o","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"189",2017-03-02,140,"12:48 PM",30,"F","Dr Alaf Khan","Dentist","4 Unit Bridge",8000,8000,NA,"Dr Ammad",8000,"Saima",NA +"190",2017-03-02,46,"03:00 PM",17,"M","Nursing Staff",NA,"Injection",50,50,NA,"Dr Ammad",50,"Saima",NA +"191",2017-03-02,114,"07:05 PM",26,"F","Dr Kinza Alam","Gynae","Consultation",1000,1000,NA,"Dr Ammad",300,"Saima",NA +"192",2017-03-02,3,NA,NA,NA,"Nursing Staff",NA,"Dressing",100,100,NA,"Dr Ammad",100,"Saima",NA +"193",2017-03-03,138,"11:20 AM",45,"F","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"194",2017-03-03,107,"12:30 PM",17,"F","Dr Alaf Khan","Dentist","R.C.T+Crown",8000,8000,NA,"Dr Ammad",8000,"Saima","3/9/2017" +"195",2017-03-03,34,"01:30 PM",22,"M","Dr Alaf Khan","Dentist","Crown",2000,2000,NA,"Dr Ammad",2000,"Saima","3/8/2017" +"196",2017-03-03,133,"04:10 PM",30,"F","Dr Ali","Child Specialist","Consultation",1000,1000,NA,"Dr Ammad",300,"Saima",NA +"197",2017-03-03,46,"05:45 PM",17,"M","Nursing Staff",NA,"Dressing",300,300,NA,"Dr Ammad",300,"Saima",NA +"198",2017-03-03,74,"02:40 PM",38,"M","Dr Waqar Azeem","Radiologist","USG KUB",1000,1000,NA,"Dr Ammad",300,"Sub KB",NA +"199",2017-03-05,46,NA,17,"M","Nursing Staff",NA,"Dressing",300,300,NA,"Dr Ammad",200,"Saima",NA +"200",2017-03-06,83,"01:20 PM",34,"M","Dr Alaf Khan","Dentist","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"201",2017-03-06,61,"05:30 PM",28,"F","Dr Qurat ul Ain","Dentist","Consultation+X Ray",950,950,NA,"Dr Ammad",950,"Haris",NA +"202",2017-03-06,122,"07:00 PM",78,"M","Nursing Staff",NA,"Injection",100,100,NA,"Dr Ammad",100,"Saima",NA +"203",2017-03-07,95,NA,56,"M","Dr Alaf Khan","Dentist","X Ray",300,300,NA,"Dr Ammad",300,"Saima",NA +"204",2017-03-07,69,"03:00 PM",53,"M","Dr Alaf Khan","Dentist",NA,15000,15000,NA,"Dr Ammad",15000,"Mona",NA +"205",2017-03-07,146,NA,21,"M","Dr Ammad","M/o","Consultation",500,500,NA,"Dr Ammad",500,"Saima",NA +"206",2017-03-07,46,"07:40 PM",17,"M","Nursing Staff",NA,"Dressing",200,200,NA,"Dr Ammad",200,"Saima",NA +"207",2017-03-07,32,"02:00 PM",NA,"F","Nursing Staff",NA,"Coupety",300,300,NA,"Dr Ammad",300,"Saima",NA +"208",2017-03-07,122,"09:35 PM",78,"M","Nursing Staff",NA,"Injection",100,100,NA,"Dr Ammad",100,"Sub KB",NA +"209",2017-03-08,148,"08:30 PM",3,"F","Nursing Staff",NA,"Injection",100,100,NA,"Dr Ammad",100,"Ashfaq",NA +"210",2017-03-08,122,"10:00 PM",76,"M","Nursing Staff",NA,"Injection",100,100,NA,"Dr Ammad",100,"Ashfaq",NA +"211",2017-03-08,10,"04:45 PM",9,"F","Dr Qurat ul Ain","Dentist","Consultation+x Ray",650,650,NA,"Dr Ammad",650,"Saima",NA +"212",2017-03-08,76,"06:55 PM",32,"M","Dr Paul","Dermatologist","Consultation",1500,1000,500,"Dr Ammad",300,"Mona",NA +"213",2017-03-08,1,"12:00 PM",NA,"F","Nursing Staff",NA,"Injection",150,150,NA,"Dr Ammad",150,"Mona",NA +"214",2017-03-08,25,"07:30 PM",NA,"F","Dr Kinza Alam","Gynae","Consultation",1500,1500,NA,"Dr Ammad",500,"Mona",NA +"215",2017-03-09,77,"12:00 PM",24,"M","Dr Alaf Khan","Dentist","R.C.T",5000,2000,3000,"Dr Ammad",2000,"Haris","3/16/2017" +"216",2017-03-09,121,"09:00 AM",3,"F","Nursing Staff",NA,"Injection",100,100,NA,"Dr Ammad",100,"Mona",NA +"217",2017-03-09,122,NA,76,"M","Nursing Staff",NA,"Injection",100,100,NA,"Dr Ammad",100,"Mona",NA +"218",2017-03-09,1,NA,NA,NA,"Nursing Staff",NA,NA,NA,NA,NA,"Dr Ammad",NA,"Saima",NA +"219",2017-03-09,18,"03:30 PM",39,"M","Dr Alaf Khan","Dentist","Scalling+Polishing",4000,4000,NA,"Dr Ammad",4000,"Saima",NA +"220",2017-03-09,110,"06:00 PM",30,"M","Dr Qurat ul Ain","Dentist","Consultation",200,200,NA,"Dr Ammad",200,"Saima",NA +"221",2017-03-10,122,"10:20 AM",76,"M","Nursing Staff",NA,"Injection",100,100,NA,"Dr Ammad",100,"Zaheer",NA +"222",2017-03-10,105,"11:20 PM",45,"F","Dr Shireen","M/o","Consultation",800,800,NA,"Dr Ammad",800,"Mona",NA diff --git a/R_Markdown_HAK.Rmd b/R_Markdown_HAK.Rmd new file mode 100644 index 0000000..8d45fdb --- /dev/null +++ b/R_Markdown_HAK.Rmd @@ -0,0 +1,177 @@ +--- +title: "Assignment_2" +author: "HAK" +date: "25 March 2017" +output: pdf_document +--- + +```{r Importing Libraries, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +#importing library +library(dplyr) +library(tidyr) +library(lubridate) +``` + +## R ASSIGNMENT 2 + +Assignment 2 of a hospital data. + +```{r Importing CSV, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +#loading csv from directory +bufferedDataFrame <- read.csv("hospitaldata.csv", strip.white = T, na.strings = c("-",""," ","\t","\n",NA), stringsAsFactors = F) +``` + +```{r Cleaning Data and Proper Conversion to Variables, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +#CLEANING DATA +#converting to tbl format +df <- tbl_df(bufferedDataFrame) + +#1. Removing dots(.) from column names +names(df) <- gsub("\\.", "", names(df)) + +#Removing character from Age Like M +df$Age <- as.numeric(gsub("[^0-9]",'',df$Age)) + +#Cleaning Date Column +#Converting date factor format to Date class +df$Date <- as.Date(strptime(df$Date, "%a, %B %d, %Y")) + +#Cleaning Time Column with formatting +df$Time <- format(strptime(df$Time, format='%I:%M %p'), '%I:%M %p') + +#Changing case of Sex to upper case +df$Sex <- toupper(df$Sex) + +#Remove Cancelled to NA as no payment is not given +df$TotalCharges <- as.numeric(gsub("cancelled", NA, ignore.case = T,df$TotalCharges)) + +#Remove Cancelled to NA as no consultation is not given +df$Procedure <- (gsub("cancelled", NA, ignore.case = T,df$Procedure)) + +#Coverting AmountBalance to numeric +df$AmountBalance <- as.numeric(gsub(",",'',df$AmountBalance)) +class(df$AmountBalance) + +#Exporting Clean CSV +write.csv(df, "CleanHospitalData.csv") + +#View clean data +glimpse(df) +View(df) +``` + +```{r Questions} +#QUESTIONS +#2. Which day of the week is expected to have most visits? +print(paste("Average age of a person is",weekdays(df$Date[which(table(df$Date) == max(table(df$Date)))]))) + +#3. What is the average age of patients? +print(paste("Average age of a person is ",mean(df$Age, na.rm = T))) + +#4. How many children were entertained? (Make a Bracket of Age from 1-12) +total_entertained <- df %>% + select(Age) %>% + filter(Age >= 1 & Age <= 12, !is.na(.)) %>% + count() +paste("Children that were entertained are", total_entertained) + +#5. Which gender type had what kind of procedure in abundance? i.e. Female visit mostly because of Gynae Problem +df %>% + group_by(Sex, Procedure) %>% + tally(sort = T) %>% + filter(!is.na(Sex)) %>% + View() + +#6. Which Doctor is earning highest? +highest_earning_doctor <- df %>% + group_by(ConsultingDoctor) %>% + summarise_each(funs(sum(TotalCharges, na.rm = T))) %>% + select(ConsultingDoctor, TotalCharges) %>% + arrange(desc(TotalCharges)) + +paste("Highest paid doctor is",(highest_earning_doctor$ConsultingDoctor[which(highest_earning_doctor$TotalCharges == max(highest_earning_doctor$TotalCharges))]), "with pay of",max(highest_earning_doctor$TotalCharges)) + +#7. Which procedure type earns more money? +highest_earning_procedure <- df %>% + group_by(Procedure) %>% + summarise_each(funs(sum(TotalCharges, na.rm = T))) %>% + select(Procedure, TotalCharges) %>% + filter(!is.na(Procedure)) %>% + arrange(desc(TotalCharges)) +View(highest_earning_procedure) +paste("Highest earning procedure is",(highest_earning_procedure$Procedure[which(highest_earning_procedure$TotalCharges == max(highest_earning_procedure$TotalCharges))]), "worth of",max(highest_earning_procedure$TotalCharges)) + +#8. Which time of the day has highest frequency of visits by hour? +high_frequency_time <- df %>% + filter(!is.na(Date), !is.na(Time)) %>% + group_by(Date,Time) %>% + tally() %>% + arrange(desc(n)) +View(high_frequency_time) +indexOfMax <- which(high_frequency_time$n == max(high_frequency_time$n)) +paste("Highest number of visits were on",weekdays(high_frequency_time$Date[indexOfMax]),"at",format(high_frequency_time$Time[indexOfMax])) + +#10. How many patients are repeated visitors? +visitor <- df %>% + group_by(id) %>% + tally() %>% + filter(n > 1) %>% + arrange(desc(n)) +View(visitor) +paste("Number of repeated visitors are", count(visitor)) + +#11. Give us the id of repeated visitors. +#Data is take from above +View(visitor) +print(visitor$id) + +#12. Which patients visited again for the same problem? +patients_repeated <- df %>% + group_by(id, Procedure) %>% + tally() %>% + filter(!is.na(Procedure), n > 1) %>% + arrange(desc(n)) +View(patients_repeated) +#This data show ignoring NA for procedure variable +paste("Patient repeated most for is",(patients_repeated$Procedure[which(patients_repeated$n == max(patients_repeated$n))])) + +#13. What is the median age for Females and Males? +df %>% + group_by(Sex) %>% + summarise(median(Age, na.rm = T)) + +#14. What is the total amount in balance? +paste("Total amount in balance is",sum(df$AmountBalance, na.rm = T)) + +#15. How much money was made by Procedure Type "Consultation"? +df %>% + group_by(Procedure) %>% + summarise(Total_Amount = sum(TotalCharges, na.rm = T)) %>% + filter(Procedure %in% c("Consultation")) + +#16.Is there a relation between Age and Total Charges paid +data <- df %>% + filter(!is.na(Age), !is.na(TotalCharges)) +paste(cor(data$Age, data$TotalCharges),"shows positive linearly directly propotional.") + +#17. Which Age group had highest number of visits? +# HIGHEST NUMBER OF VISIT WAS BY AGE UNASIGNED 'NA' THAT IS 28 BUT IT WAS IGNORED +highest_age_visit <- df %>% + group_by(Age) %>% + tally() %>% + filter(!is.na(Age)) %>% + arrange(desc(n)) +View(highest_age_visit) +paste("Highest number of visit was by age group of",(highest_age_visit$Age[which(highest_age_visit$n == max(highest_age_visit$n))]), "with number of visits of",max(highest_age_visit$n)) + +#18. What is the total cost earned by Procedure Type X Ray and Scalling together? +TotalEarning <- df %>% + filter(Procedure %in% c("X Ray", "Scalling")) %>% + summarise(Total = sum(TotalCharges, na.rm = T)) +View(TotalEarning) +paste("Total earning by both X Ray and Scalling is worth",TotalEarning) + +``` \ No newline at end of file diff --git a/R_Markdown_HAK.html b/R_Markdown_HAK.html new file mode 100644 index 0000000..144ea05 --- /dev/null +++ b/R_Markdown_HAK.html @@ -0,0 +1,281 @@ + + + + +
+ + + + + + + + + + +Assignment 2 of a hospital data.
+#QUESTIONS
+#2. Which day of the week is expected to have most visits?
+print(paste("Average age of a person is",weekdays(df$Date[which(table(df$Date) == max(table(df$Date)))])))
+## [1] "Average age of a person is Monday"
+#3. What is the average age of patients?
+print(paste("Average age of a person is ",mean(df$Age, na.rm = T)))
+## [1] "Average age of a person is 32.5721649484536"
+#4. How many children were entertained? (Make a Bracket of Age from 1-12)
+total_entertained <- df %>%
+ select(Age) %>%
+ filter(Age >= 1 & Age <= 12, !is.na(.)) %>%
+ count()
+paste("Children that were entertained are", total_entertained)
+## [1] "Children that were entertained are 24"
+#5. Which gender type had what kind of procedure in abundance? i.e. Female visit mostly because of Gynae Problem
+df %>%
+ group_by(Sex, Procedure) %>%
+ tally(sort = T) %>%
+ filter(!is.na(Sex)) %>%
+ View()
+
+#6. Which Doctor is earning highest?
+highest_earning_doctor <- df %>%
+ group_by(ConsultingDoctor) %>%
+ summarise_each(funs(sum(TotalCharges, na.rm = T))) %>%
+ select(ConsultingDoctor, TotalCharges) %>%
+ arrange(desc(TotalCharges))
+
+paste("Highest paid doctor is",(highest_earning_doctor$ConsultingDoctor[which(highest_earning_doctor$TotalCharges == max(highest_earning_doctor$TotalCharges))]), "with pay of",max(highest_earning_doctor$TotalCharges))
+## [1] "Highest paid doctor is Dr Alaf Khan with pay of 513050"
+#7. Which procedure type earns more money?
+highest_earning_procedure <- df %>%
+ group_by(Procedure) %>%
+ summarise_each(funs(sum(TotalCharges, na.rm = T))) %>%
+ select(Procedure, TotalCharges) %>%
+ filter(!is.na(Procedure)) %>%
+ arrange(desc(TotalCharges))
+View(highest_earning_procedure)
+paste("Highest earning procedure is",(highest_earning_procedure$Procedure[which(highest_earning_procedure$TotalCharges == max(highest_earning_procedure$TotalCharges))]), "worth of",max(highest_earning_procedure$TotalCharges))
+## [1] "Highest earning procedure is Orthodontics worth of 240000"
+#8. Which time of the day has highest frequency of visits by hour?
+high_frequency_time <- df %>%
+ filter(!is.na(Date), !is.na(Time)) %>%
+ group_by(Date,Time) %>%
+ tally() %>%
+ arrange(desc(n))
+View(high_frequency_time)
+indexOfMax <- which(high_frequency_time$n == max(high_frequency_time$n))
+paste("Highest number of visits were on",weekdays(high_frequency_time$Date[indexOfMax]),"at",format(high_frequency_time$Time[indexOfMax]))
+## [1] "Highest number of visits were on Wednesday at 02:40 PM"
+#10. How many patients are repeated visitors?
+visitor <- df %>%
+ group_by(id) %>%
+ tally() %>%
+ filter(n > 1) %>%
+ arrange(desc(n))
+View(visitor)
+paste("Number of repeated visitors are", count(visitor))
+## [1] "Number of repeated visitors are 37"
+#11. Give us the id of repeated visitors.
+#Data is take from above
+View(visitor)
+print(visitor$id)
+## [1] 1 46 122 17 94 140 45 63 101 107 109 114 132 145 4 12 13
+## [18] 20 25 40 59 64 80 88 96 97 100 112 116 118 120 130 133 149
+## [35] 150 151 153
+#12. Which patients visited again for the same problem?
+patients_repeated <- df %>%
+ group_by(id, Procedure) %>%
+ tally() %>%
+ filter(!is.na(Procedure), n > 1) %>%
+ arrange(desc(n))
+View(patients_repeated)
+#This data show ignoring NA for procedure variable
+paste("Patient repeated most for is",(patients_repeated$Procedure[which(patients_repeated$n == max(patients_repeated$n))]))
+## [1] "Patient repeated most for is Pharmacy"
+#13. What is the median age for Females and Males?
+df %>%
+ group_by(Sex) %>%
+ summarise(median(Age, na.rm = T))
+## # A tibble: 3 × 2
+## Sex `median(Age, na.rm = T)`
+## <chr> <dbl>
+## 1 F 30
+## 2 M 29
+## 3 <NA> NA
+#14. What is the total amount in balance?
+paste("Total amount in balance is",sum(df$AmountBalance, na.rm = T))
+## [1] "Total amount in balance is 222500"
+#15. How much money was made by Procedure Type "Consultation"?
+df %>%
+ group_by(Procedure) %>%
+ summarise(Total_Amount = sum(TotalCharges, na.rm = T)) %>%
+ filter(Procedure %in% c("Consultation"))
+## # A tibble: 1 × 2
+## Procedure Total_Amount
+## <chr> <dbl>
+## 1 Consultation 83950
+#16.Is there a relation between Age and Total Charges paid
+data <- df %>%
+ filter(!is.na(Age), !is.na(TotalCharges))
+paste(cor(data$Age, data$TotalCharges),"shows positive linearly directly propotional.")
+## [1] "0.0295206461012257 shows positive linearly directly propotional."
+#17. Which Age group had highest number of visits?
+# HIGHEST NUMBER OF VISIT WAS BY AGE UNASIGNED 'NA' THAT IS 28 BUT IT WAS IGNORED
+highest_age_visit <- df %>%
+ group_by(Age) %>%
+ tally() %>%
+ filter(!is.na(Age)) %>%
+ arrange(desc(n))
+View(highest_age_visit)
+paste("Highest number of visit was by age group of",(highest_age_visit$Age[which(highest_age_visit$n == max(highest_age_visit$n))]), "with number of visits of",max(highest_age_visit$n))
+## [1] "Highest number of visit was by age group of 30 with number of visits of 20"
+#18. What is the total cost earned by Procedure Type X Ray and Scalling together?
+TotalEarning <- df %>%
+ filter(Procedure %in% c("X Ray", "Scalling")) %>%
+ summarise(Total = sum(TotalCharges, na.rm = T))
+View(TotalEarning)
+paste("Total earning by both X Ray and Scalling is worth",TotalEarning)
+## [1] "Total earning by both X Ray and Scalling is worth 22300"
+library(dplyr)
+##
+## Attaching package: 'dplyr'
+## The following objects are masked from 'package:stats':
+##
+## filter, lag
+## The following objects are masked from 'package:base':
+##
+## intersect, setdiff, setequal, union
+library(tidyr)
+library(lubridate)
+##
+## Attaching package: 'lubridate'
+## The following object is masked from 'package:base':
+##
+## date
+#loading csv from directory
+bufferedDataFrame <- read.csv("hospitaldata.csv", strip.white = T, na.strings = c("-",""," ","\t","\n",NA), stringsAsFactors = F)
+
+#CLEANING DATA
+#converting to tbl format
+df <- tbl_df(bufferedDataFrame)
+
+#1. Removing dots(.) from column names
+names(df) <- gsub("\\.", "", names(df))
+
+#Removing character from Age Like M
+df$Age <- as.numeric(gsub("[^0-9]",'',df$Age))
+
+#Cleaning Date Column
+#Converting date factor format to Date class
+df$Date <- as.Date(strptime(df$Date, "%a, %B %d, %Y"))
+
+#Cleaning Time Column with formatting
+df$Time <- format(strptime(df$Time, format='%I:%M %p'), '%I:%M %p')
+
+#Changing case of Sex to upper case
+df$Sex <- toupper(df$Sex)
+
+#Remove Cancelled to NA as no payment is not given
+df$TotalCharges <- as.numeric(gsub("cancelled", NA, ignore.case = T,df$TotalCharges))
+
+#Remove Cancelled to NA as no consultation is not given
+df$Procedure <- (gsub("cancelled", NA, ignore.case = T,df$Procedure))
+
+#Coverting AmountBalance to numeric
+df$AmountBalance <- as.numeric(gsub(",",'',df$AmountBalance))
+class(df$AmountBalance)
+## [1] "numeric"
+#Exporting Clean CSV
+write.csv(df, "CleanHospitalData.csv")
+
+#View clean data
+glimpse(df)
+## Observations: 222
+## Variables: 15
+## $ Date <date> 2017-01-01, 2017-01-02, 2017-01-02, 2017-01-...
+## $ id <int> 101, 150, 58, 75, 97, 101, 26, 149, 20, 72, 5...
+## $ Time <chr> "11:00 AM", "10:45 AM", "12:38 PM", "01:00 PM...
+## $ Age <dbl> 40, 26, 30, 40, 27, 40, 43, 28, 2, 40, 32, 28...
+## $ Sex <chr> "F", "M", "F", "M", "M", "F", "M", "F", "F", ...
+## $ ConsultingDoctor <chr> "Dr Kinza Alam", "Nursing Staff", "Dr Riffat ...
+## $ Specialty <chr> "Gynae", NA, "Psychotherapist", "Psychotherap...
+## $ Procedure <chr> "C Section", "Dressing", "Consultation", "Con...
+## $ TotalCharges <dbl> 30000, 1500, 1000, 1500, 2000, 35000, 2000, 5...
+## $ AmountReceived <int> 30000, 1500, 1000, 1500, 2000, 35000, 2000, 5...
+## $ AmountBalance <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
+## $ AmountReceivedBy <chr> "Mrs Shamsa", "Dr Saniya", "Mrs Shamsa", "Mrs...
+## $ AmountinHospital <int> NA, NA, 300, 450, 600, NA, NA, 500, NA, 500, ...
+## $ ReceptionistName <chr> "Hamza", "Haris", "Fiza", "Zaheer", "Haris", ...
+## $ NextApt <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "...
+View(df)
+
+#QUESTIONS
+#2. Which day of the week is expected to have most visits?
+print(paste("Average age of a person is",weekdays(df$Date[which(table(df$Date) == max(table(df$Date)))])))
+## [1] "Average age of a person is Monday"
+#3. What is the average age of patients?
+print(paste("Average age of a person is ",mean(df$Age, na.rm = T)))
+## [1] "Average age of a person is 32.5721649484536"
+#4. How many children were entertained? (Make a Bracket of Age from 1-12)
+total_entertained <- df %>%
+ select(Age) %>%
+ filter(Age >= 1 & Age <= 12, !is.na(.)) %>%
+ count()
+paste("Children that were entertained are", total_entertained)
+## [1] "Children that were entertained are 24"
+#5. Which gender type had what kind of procedure in abundance? i.e. Female visit mostly because of Gynae Problem
+df %>%
+ group_by(Sex, Procedure) %>%
+ tally(sort = T) %>%
+ filter(!is.na(Sex)) %>%
+ View()
+
+#6. Which Doctor is earning highest?
+highest_earning_doctor <- df %>%
+ group_by(ConsultingDoctor) %>%
+ summarise_each(funs(sum(TotalCharges, na.rm = T))) %>%
+ select(ConsultingDoctor, TotalCharges) %>%
+ arrange(desc(TotalCharges))
+
+paste("Highest paid doctor is",(highest_earning_doctor$ConsultingDoctor[which(highest_earning_doctor$TotalCharges == max(highest_earning_doctor$TotalCharges))]), "with pay of",max(highest_earning_doctor$TotalCharges))
+## [1] "Highest paid doctor is Dr Alaf Khan with pay of 513050"
+#7. Which procedure type earns more money?
+highest_earning_procedure <- df %>%
+ group_by(Procedure) %>%
+ summarise_each(funs(sum(TotalCharges, na.rm = T))) %>%
+ select(Procedure, TotalCharges) %>%
+ filter(!is.na(Procedure)) %>%
+ arrange(desc(TotalCharges))
+View(highest_earning_procedure)
+paste("Highest earning procedure is",(highest_earning_procedure$Procedure[which(highest_earning_procedure$TotalCharges == max(highest_earning_procedure$TotalCharges))]), "worth of",max(highest_earning_procedure$TotalCharges))
+## [1] "Highest earning procedure is Orthodontics worth of 240000"
+#8. Which time of the day has highest frequency of visits by hour?
+#It its only about number of highes frequency
+#"01:00 PM" "01:30 PM" "03:00 PM" "12:00 PM"
+high_time_repeated <- df %>%
+ filter(!is.na(Time)) %>%
+ group_by(Time) %>%
+ tally() %>%
+ arrange(desc(n))
+View(high_time_repeated)
+high_time_repeated$Time[high_time_repeated$n == max(high_time_repeated$n)]
+## [1] "01:00 PM" "01:30 PM" "03:00 PM" "12:00 PM"
+#If your are talking about particular day
+high_frequency_time <- df %>%
+ filter(!is.na(Date), !is.na(Time)) %>%
+ group_by(Date,Time) %>%
+ tally() %>%
+ arrange(desc(n))
+View(high_frequency_time)
+indexOfMax <- which(high_frequency_time$n == max(high_frequency_time$n))
+paste("Highest number of visits were on",weekdays(high_frequency_time$Date[indexOfMax]),"at",format(high_frequency_time$Time[indexOfMax]))
+## [1] "Highest number of visits were on Wednesday at 02:40 PM"
+#9. Create a bracket of time by Morning, Afternoon, Evening, Night (6am - 12pm - Morning, 12 pm- 4 pm, Afternoon, 4 pm- 7pm, Evening, 7pm - 6 am, Night).
+
+hour(strptime(df$Time, "%I:%M %p"))
+## [1] 11 10 12 13 14 15 15 15 15 17 17 17 13 15 18 23 12 20 20 12 14 14 12
+## [24] 13 13 NA 20 NA 12 13 14 15 17 17 15 18 NA NA 15 16 16 10 14 14 11 15
+## [47] 20 16 18 21 NA 13 18 18 11 11 13 15 18 21 12 14 17 NA 11 NA NA NA 10
+## [70] 13 13 12 13 13 16 13 13 14 13 NA NA 12 15 17 NA NA NA NA 18 21 NA 13
+## [93] 13 17 17 18 17 18 18 14 14 13 13 18 12 13 13 16 20 16 16 19 19 13 13
+## [116] 16 18 12 13 14 18 20 10 12 12 14 14 14 10 9 18 19 12 16 17 18 19 12
+## [139] 11 15 19 NA 14 15 19 11 16 18 16 17 18 18 18 11 14 NA 13 14 19 22 13
+## [162] 18 19 22 NA 15 16 17 13 13 14 15 21 15 16 11 12 NA 22 12 NA 15 20 17
+## [185] 18 NA 19 19 12 15 19 NA 11 12 13 16 17 14 NA 13 17 19 NA 15 NA 19 14
+## [208] 21 20 22 16 18 12 19 12 9 NA NA 15 18 10 23
+df %>%
+ mutate(TimeBracket = ifelse(hour(strptime(df$Time, "%I:%M %p")) >= 6 & hour(strptime(df$Time, "%I:%M %p")) <= 12, "Morning",
+ ifelse(hour(strptime(df$Time, "%I:%M %p")) > 12 & hour(strptime(df$Time, "%I:%M %p")) <= 16, "Afternoon",
+ ifelse(hour(strptime(df$Time, "%I:%M %p")) > 16 & hour(strptime(df$Time, "%I:%M %p")) <= 19, "Evening",
+ ifelse(hour(strptime(df$Time, "%I:%M %p")) > 19, "Night", NA))))) %>%
+ View()
+
+
+
+#10. How many patients are repeated visitors?
+visitor <- df %>%
+ group_by(id) %>%
+ tally() %>%
+ filter(n > 1) %>%
+ arrange(desc(n))
+View(visitor)
+paste("Number of repeated visitors are", count(visitor))
+## [1] "Number of repeated visitors are 37"
+#11. Give us the id of repeated visitors.
+#Data is take from above
+View(visitor)
+print(visitor$id)
+## [1] 1 46 122 17 94 140 45 63 101 107 109 114 132 145 4 12 13
+## [18] 20 25 40 59 64 80 88 96 97 100 112 116 118 120 130 133 149
+## [35] 150 151 153
+#12. Which patients visited again for the same problem?
+patients_repeated <- df %>%
+ group_by(id, Procedure) %>%
+ tally() %>%
+ filter(!is.na(Procedure), n > 1) %>%
+ arrange(desc(n))
+View(patients_repeated)
+#This data show ignoring NA for procedure variable
+paste("Patient repeated most for is",(patients_repeated$Procedure[which(patients_repeated$n == max(patients_repeated$n))]))
+## [1] "Patient repeated most for is Pharmacy"
+#13. What is the median age for Females and Males?
+df %>%
+ group_by(Sex) %>%
+ summarise(median(Age, na.rm = T))
+## # A tibble: 3 × 2
+## Sex `median(Age, na.rm = T)`
+## <chr> <dbl>
+## 1 F 30
+## 2 M 29
+## 3 <NA> NA
+#14. What is the total amount in balance?
+paste("Total amount in balance is",sum(df$AmountBalance, na.rm = T))
+## [1] "Total amount in balance is 222500"
+#15. How much money was made by Procedure Type "Consultation"?
+df %>%
+ group_by(Procedure) %>%
+ summarise(Total_Amount = sum(TotalCharges, na.rm = T)) %>%
+ filter(Procedure %in% c("Consultation"))
+## # A tibble: 1 × 2
+## Procedure Total_Amount
+## <chr> <dbl>
+## 1 Consultation 83950
+#16.Is there a relation between Age and Total Charges paid
+data <- df %>%
+ filter(!is.na(Age), !is.na(TotalCharges))
+paste(cor(data$Age, data$TotalCharges),"shows positive linearly directly propotional.")
+## [1] "0.0295206461012257 shows positive linearly directly propotional."
+#17. Which Age group had highest number of visits?
+# HIGHEST NUMBER OF VISIT WAS BY AGE UNASIGNED 'NA' THAT IS 28 BUT IT WAS IGNORED
+highest_age_visit <- df %>%
+ group_by(Age) %>%
+ tally() %>%
+ filter(!is.na(Age)) %>%
+ arrange(desc(n))
+View(highest_age_visit)
+paste("Highest number of visit was by age group of",(highest_age_visit$Age[which(highest_age_visit$n == max(highest_age_visit$n))]), "with number of visits of",max(highest_age_visit$n))
+## [1] "Highest number of visit was by age group of 30 with number of visits of 20"
+#18. What is the total cost earned by Procedure Type X Ray and Scalling together?
+TotalEarning <- df %>%
+ filter(Procedure %in% c("X Ray", "Scalling")) %>%
+ summarise(Total = sum(TotalCharges, na.rm = T))
+View(TotalEarning)
+paste("Total earning by both X Ray and Scalling is worth",TotalEarning)
+## [1] "Total earning by both X Ray and Scalling is worth 22300"
+
+
+
+
+