Note: on data sets

You may use any data of your choosing in the following problems, but I would suggest you choose a data set you find interesting or would give an interesting graph (so, don’t use something like the old iris data set). You will get more out of the project in the end, and it will look better to those in the future you are showing it to. If the data set comes from an R package then reference this. If the data set is from elsewhere, then upload a copy to blackboard (.csv format).


Problem 1 [20 points]

Create a plotly graph of your choosing that represents at least two variables, one of which must be a categorical variable.

This plot can be a scatter plot, overlayed density plots (graphing variable is continuous, separate densities grouped by categorical variable), etc. choropleth maps could also be on the list…you have to admit they look kinda cool.

The graph must include:

  1. customized hover text that is informative to the graphing elements in the plot

  2. separate color to represent groups

  3. labeled axes and appropriate title

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(plotly)
## Warning: package 'plotly' was built under R version 4.5.2
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.5.2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
mpg %>%
  plot_ly(x = ~displ, y = ~hwy,
          hoverinfo = "text",
          text = ~manufacturer, color = ~drv, type="scatter", mode="markers")%>%
  layout(xaxis = list(title = "Engine displacement in Liters (engine size)"),
         yaxis = list(title = "Highway average miles per gallon"),
         title = "Highway Miles Per Gallon vs Engine Size by Drive Train")

Include at least a 1-paragraph discussion about the graph. Discuss what is being plotted and what information is being displayed in the graph. Discuss any information that the reader may gain from hovering the cursor over graphing elements. Discuss any issues/chalenges you had (if any) while making the plot, and you you dealt with or overcame them.

For this viualization I used the mpg dataset from the ggplot2 package to create the scatterplot highway fuel efficiency (hwy, in miles per gallon) on the vertical axis against engine displacement (displ, in liters) on the horizontal axis, with points colored by the categorical variable drive train. Then with the addition of my hover text on each point we can see each indivdual points manufacturer so the viewer could have a more complete picture of the vehicle information if a specidic point gained their interest. Overall, the plot reveals a negative relationship between engine size and hwy mpg. We see vehicles with smaller engines have noticeably higher highway mileage, whereas vehicles with larger engines tend to get lower highway MPG. Separating the data by drive train alos shows us that front wheel drive vehicles tend to have smaller engine sizes and higher highway fuel efficiency, while four wheel drive and rear wheel drive vehicles have larger engines and lower MPG. One minor challenge I encountered while building the plot was ensuring that plot_ly() displayed a = scatter plot without generating warnings but specifying type = “scatter” and mode = “markers” fixed these warnings.


Problem 2 [20 points]

Create an animated plotly graph with a data set of your choosing. This can be, but does not have to be a scatter plot. Also, the animation does not have to take place over time. As mentioned in the notes, the frame can be set to a categorical variable. However, the categories the frames cycle through should be organized (if needs be) such that the progression through them shows some pattern or trend.

This graph should include:

  1. Aside from the graphing variable, a separate categorical variable. For example, in our animated scatter plot we color grouped the points by continent.

  2. Appropriate axis labels and a title

  3. Augment the frame label to make it more visible. This can include changing the font size and color to make it stand out more, and/or moving the frame label to a new location in the plotting region. Note, if you do this, make sure it is still clearly visible and does not obstruct the view of your plot.

library(dplyr)
library(plotly)

erp <- read.csv("ERP_System_Effectiveness_Updated_80000.csv")

set.seed(123)
erp_anim <- erp %>%
  sample_n(2500) %>%
  mutate(Tenure_Year = cut(
      ERP_Tenure_Months,
      breaks = seq(0, 120, by = 12),
      labels = paste("Year", 1:10)
    )
  )

erp_anim %>%
  plot_ly( x = ~User_Training_Hours, y = ~Process_Error_Rate_Pct,
    hoverinfo = "text",
    text = ~Organization_Size) %>%
  add_markers(frame = ~Tenure_Year,color = ~Organization_Size) %>%
  layout(title = "Process Error Rate vs. User Training Hours by Organization Size",
    xaxis = list(title = "User Training Hours"),
    yaxis = list(title = "Process Error Rate (%)")) %>%
  animation_opts(frame = 1700, transition = 600) %>%
  animation_slider(currentvalue = list(font = list(color = "black", size = 14)))

Include at least a 1-paragraph discussion about the plot. Discuss what you are plotting and what trends can be seen throughout the animation. Discuss any issues, if any, you ran into in making the plot and how you overcame them.

The data That I selected wads a sample dataset from kaggle, based on data governance/quality regarding to different organizations adopting am ERP system. This is something that I deal with everyday in my internship, so I was curious on how I could use my R skills within my knowledge of data governance and ERP crossovers and migrations. On the x axis of my graph is the user training hours, the amount of time decicated to educating users within the ERP system how to use it. the y axis is the process error rate percentage which is the percentage of errors within the ERP system that occurs out of all the processes of that month.the categories I assigned were the organization size, so we could see if there were any different in ERP training and performance at different size organizations. my frame is moving by each year, so every 12 months that the company has adopted the ERP system, Before this graph I expected to see that as time went on in the graph we would see a decrease in errors, I also thought that maybe with the companies with a larger amount of training, we would see less errors occurring as well. However, looking at my graph I couldnt see any obvious patterns with my data other than that most companies had around 10-20 hours of training for their users. The only issues I really had with this graph was my previous trials with different datasets that just didnt really look good due to different frame values and their being only one data point on each screen and me not really being sure on how I should group them together without clouding the real datas relationship with the other factors. I just changed my data set to one with a time parameter to change this. What to turn in: