-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathQ7.R
More file actions
28 lines (21 loc) · 867 Bytes
/
Q7.R
File metadata and controls
28 lines (21 loc) · 867 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
27
28
#Question 7
#Repeating previous code snippet
library("ggplot2")
library("lubridate")
library("dplyr")
library("tidyr")
library("DataCombine")
bufferedDataFrame <- read.csv("C:/Users/umair.hanif/Desktop/Learning Outcomes/AR/hospitaldata.csv", strip.white = T, na.strings = c("-",""," ","\t","\n",NA), stringsAsFactors = F)
dataf <- tbl_df(bufferedDataFrame)
View(dataf)
glimpse(dataf)
#removing character from age M
dataf$Age <- as.numeric(gsub("[^0-9]",'',dataf$Age))
class(dataf$Age)
unique(dataf$Age)
# Question #1
#Changing Datatypes from factor to their required formats
names(dataf) <- gsub("\\.",'',names(dataf))
#now lets play with date
dataf$Date <- as.Date(strptime(dataf$Date, "%a, %B %d, %Y"))
qplot(data=dataf, as.numeric(TotalCharges), fill=Procedure)+ggtitle("Highest Procedure")+labs(x='TotalCharges',y='Procedure')