Description
#Load Packages
“`{r}
library(randomForest)
library(ggplot2)
library(MASS)
library(caret)
library(gbm)
library(readr)
library(rpart)
library(tree)
library(ISLR)
library(tidyverse)
library(rpart.plot)
library(sp)
library(CASdatasets)
library(class)
library(pROC)
“`
“`{r}
data(credit)
#all of the data that needs to be factors (discrete.)
columns_to_convert <- c("purpose", "checking_status", "credit_history", "savings", "employment", "personal_status", "other_parties", "property_magnitude", "other_payment_plans", "housing", "job", "telephone", "foreign_worker","class","existing_credits","num_dependents","residence_since","installment_rate") #data that needs to be numerical (continuous) column_to_num <- c("duration", "credit_amount","age") cf <- data.frame(credit[columns_to_convert] <- lapply(credit[columns_to_convert], as.factor)) credit[column_to_num] <- lapply(credit[column_to_num],as.numeric) credit[columns_to_convert] <- lapply(credit[columns_to_convert], as.numeric) credit[columns_to_convert] <- lapply(credit[columns_to_convert], as.factor) str(credit) missval <- colSums(is.na(credit)) #legend of how each value has been transformed. print(missval) un.cr <- sapply(credit[columns_to_convert], unique) un.cf <- sapply(cf[columns_to_convert], unique) unique_df_credit <- data.frame(Variable = names(un.cr), Modified_Values = sapply(un.cr, toString), stringsAsFactors = FALSE) unique_df_cf <- data.frame(Variable = names(un.cf), Original_Values = sapply(un.cf, toString), stringsAsFactors = FALSE) merged_unique_df <- merge(unique_df_credit, unique_df_cf, by = "Variable", all = TRUE) print(merged_unique_df) #Shows what value was turned into which value factors <- sapply(credit, is.factor) continuous <- sapply(credit, is.numeric) factor_vars <- names(credit)[factors] continuous_vars <- names(credit)[continuous] summary(credit[continuous_vars]) summary(credit[factor_vars]) ``` This is the code and i want to make a report of three to four pages, about it, I will be presenting a powerpoint presentation also, so i need explanation. I have the instructions and i will send it to you