# write_csv(churn_r, "churn_r.csv")
churn_r <- read_csv("~/datanal/BA/churn_r.csv")
## Parsed with column specification:
## cols(
## Group.1 = col_character(),
## gender = col_double(),
## SeniorCitizen = col_double(),
## Partner = col_double(),
## Dependents = col_double(),
## tenure = col_double(),
## Contract = col_double(),
## PaperlessBilling = col_double(),
## MonthlyCharges = col_double(),
## TotalCharges = col_double()
## )
# churn_r$gender <- as.numeric(churn_r$gender)
# churn_r$SeniorCitizen <- as.numeric(churn_r$SeniorCitizen)
# churn_r$Partner <- as.numeric(churn_r$Partner)
# churn_r$Dependents <- as.numeric(churn_r$Dependents)
# churn_r$PhoneService <- as.numeric(churn_r$PhoneService)
# churn_r$MultipleLines <- as.numeric(churn_r$MultipleLines)
# churn_r$InternetService <- as.numeric(churn_r$InternetService)
# churn_r$OnlineSecurity <- as.numeric(churn_r$OnlineSecurity)
# churn_r$OnlineBackup <- as.numeric(churn_r$OnlineBackup)
# churn_r$DeviceProtection <- as.numeric(churn_r$DeviceProtection)
# churn_r$TechSupport <- as.numeric(churn_r$TechSupport)
# churn_r$StreamingTV <- as.numeric(churn_r$StreamingTV)
# churn_r$StreamingMovies <- as.numeric(churn_r$StreamingMovies)
# churn_r$Contract <- as.numeric(churn_r$Contract)
# churn_r$PaperlessBilling <- as.numeric(churn_r$PaperlessBilling)
# churn_r$PaymentMethod <- as.numeric(churn_r$PaymentMethod)
# churn_r <- aggregate(churn_r, list(churn_r$Churn), mean)
# churn_r <- churn_r[,c(-2, -8:-16, -19, -22)]
head(churn_r)
## # A tibble: 2 x 10
## Group.1 gender SeniorCitizen Partner Dependents tenure Contract
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 No 1.51 1.13 1.53 1.34 37.7 1.89
## 2 Yes 1.50 1.25 1.36 1.17 18.0 1.14
## # … with 3 more variables: PaperlessBilling <dbl>, MonthlyCharges <dbl>,
## # TotalCharges <dbl>
churn_r_cat <- churn_r[, c(-6,-9,-10)]
churn_r_num <- churn_r[, c(6,9)]
p <- plot_ly(
type = 'scatterpolar',
fill = 'toself'
) %>%
add_trace(
r = as.numeric(churn_r_cat[1, c(-1)]),
theta = names(churn_r_cat[,c(-1)]),
name = 'Churners'
) %>%
add_trace(
r = as.numeric(churn_r_cat[2, c(-1)]),
theta = names(churn_r_cat[,c(-1)]),
name = 'Stayers'
) %>%
layout(
polar = list(
radialaxis = list(
visible = T,
range = c(0,2)
)
)
)
p
## No scatterpolar mode specifed:
## Setting the mode to markers
## Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
## No scatterpolar mode specifed:
## Setting the mode to markers
## Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
## No scatterpolar mode specifed:
## Setting the mode to markers
## Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode