This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{# Some key packages pkgs00 <- c(“devtools”, “RCurl”) install.packages(pkgs00)
pkg01 <- c( “tidyverse”, #For data science “tidyquant”, #Financial time series “lime”, #Explaining black-box mode “glue”, #Pasting text “fs”, #File system “cowplot”, #Handle multiple ggplot “readxl”, #read excel file “writexl” #write excel file ) install.packages(pkg01)
install.packages(“pacman”) # pacman::p_install(h2o) install.packages(“h2o”) install.packages(“xlsx”) library(h2o) # h2o set-up h2o.no_progress() # turn off h2o progress bars h2o.init() # launch h2o #
library(readxl) library(pacman) p_load(tidyverse, tidyquant, lime, glue, cowplot, ggplot2,fs,readxl, writexl)
library(xlsx)
library(readr) library(writexl)
data <- read_csv(“telco_train.csv”)
write_xlsx(data, “telco_train.xlsx”)
fs::dir_create(“data”)
path_train <- “telco_train.xlsx” train_raw_tbl <- read_excel(path_train) class(train_raw_tbl)
dept_job_role_tbl <- train_raw_tbl %>% select(EmployeeNumber, Department, JobRole, PerformanceRating, Attrition)
dept_job_role_tbl %>% group_by(Attrition) %>% summarise(n = n()) %>% ungroup() %>% mutate(pct = n /sum(n)) # department attrition dept_job_role_tbl %>% group_by(Department, Attrition) %>% summarise(n = n()) %>% ungroup() %>% #group_by(Department) %>% mutate(pct = n /sum(n))
dept_job_role_tbl %>% group_by(Department, JobRole, Attrition) %>% summarise(n = n()) %>% ungroup() %>% group_by(Department, JobRole) %>% mutate(pct = n /sum(n)) %>% ungroup() %>% filter(Attrition %in% c(“Yes”)) }
```