-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRShiny CS2 EDA.Rmd
53 lines (49 loc) · 1.71 KB
/
RShiny CS2 EDA.Rmd
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
---
title: "RShiny CS2 EDA"
author: "Max Pagan"
date: "2023-12-06"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(shiny)
library(ggplot2)
library(dplyr)
```
```{r shiny}
data <- read.csv("CaseStudy2-data copy 3.csv")
data <- data[, !colnames(data) %in% c("Over18")]
data <- data[, !colnames(data) %in% c("EmployeeCount")]
data <- data[, !colnames(data) %in% c("StandardHours")]
#below is code one could use to turn certain data points to factors - commented out for now
#data$JobSatisfaction <- factor(data$JobSatisfaction)
#data$Education <- factor(data$Education)
#data$EnvironmentSatisfaction <- factor(data$EnvironmentSatisfaction)
#data$JobLevel <- factor(data$JobLevel)
#data$JobInvolvement <- factor(data$JobInvolvement)
#data$PerformanceRating <- factor(data$PerformanceRating)
#data$RelationshipSatisfaction <- factor(data$RelationshipSatisfaction)
#data$StockOptionLevel <- factor(data$StockOptionLevel)
#data$WorkLifeBalance<- factor(data$WorkLifeBalance)
# Define UI
ui <- fluidPage(
titlePanel("Scatterplot based on JobRole"),
sidebarLayout(
sidebarPanel(
# Dropdown menu for X-axis variable selection
selectInput("x_variable", "Choose X Variable", choices = colnames(data)),
# Dropdown menu for Y-axis variable selection
selectInput("y_variable", "Choose Y Variable", choices = colnames(data))
),
mainPanel(
# Scatterplot output with jitter
plotOutput("scatterplot")
)
)
)
# Define server logic
server <- function(input, output) {
# Create scatterplot based on user input
output$scatterplot <- renderPlot({
ggplot(data, aes_string(x = input$x_variable, y = input$y_variable, color = "Attrition")) +
geom_p