-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem_02_Best_Hospital_01.R
63 lines (37 loc) · 1.43 KB
/
Problem_02_Best_Hospital_01.R
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
rm(list=ls())
library(data.table)
library(dplyr)
library(naniar)
tripleoutcomes <- read.csv("C:/Users/corma/OneDrive/Documents/R/Assignment3/hospitaldata/outcomes.csv",
header = TRUE, sep = ",", stringsAsFactors = FALSE,
na.strings = "Not Available")
tripleoutcomes_the_fuck <- fread("C:/Users/corma/OneDrive/Documents/R/Assignment3/hospitaldata/outcomes.csv",
header = TRUE, sep = ",", stringsAsFactors = FALSE,
na.strings = "Not Available", select = c(2,11,17,23))
na_strings <- c("Not Available")
outcomes_cleaned <- tripleoutcomes_the_fuck %>%
replace_with_na_all(condition = ~.x %in% na_strings)
outcomes <- as.numeric(unlist(outcomes_cleaned[,c(2:4)]))
matrix <- as.matrix(outcomes_cleaned[,c(2:4)])
class(outcomes_cleaned)
dfoutcomes <- as.data.frame(outcomes_cleaned)
class(dfoutcomes)
sapply(dfoutcomes, typeof)
class(dfoutcomes)
typeof(dfoutcomes)
tib <- as_tibble(dfoutcomes)
### OMG THANK YOU ###
tibmutate <- tib %>%
mutate(across(2:4,as.numeric))
######################################
?rename
renamed <- rename(tibmutate, hospital name = Hospital, 2=Attack, 3=Failure, 4=Pneumonia)
renamed <- colnames(tibmutate) <- c("Hospital","Attack","Failure","Lungies")
str(tibmutate)
dataframe <- data.frame(dfoutcomes)
str(dataframe)
is.list(dataframe)
type?dplyr
?fread
?read.csv
?as.data.table