knitr::opts_chunk$set(echo = TRUE)
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:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
plot(pressure)
Note that the echo = TRUE parameter was added to the
code chunk to prevent printing of the R code that generated the plot.
install.packages(‘dplyr’) install.packages(“kableExtra”)
install.packages(“readr”) install.packages(“tidyverse”)
install.packages(“tidyr”) install.packages(“ggplot2”)
install.packages(“ggmap”) install.packages(“data.table”)
install.packages(“vtable”) install.packages(“magrittr”)
install.packages(“girafe”) library(dplyr) library(kableExtra)
library(vtable) vtable(zip_info, lush = TRUE) library(magrittr)
library(readr) library(tidyverse) library(tidyr) library(ggplot2)
library(ggmap) library(data.table) library(girafe)
relevant_data <- data[, c(“Do you feel safe at SU? Rate on a scale of 1-5 (1 being you DON’T feel safe, 5 being you feel safe)”, “What has your experience at Albers/SU been like?”)]
colnames(relevant_data) <- c(“Safety_Rating”, “Experience”)
relevant_data\(Experience <- tolower(relevant_data\)Experience)
correlation <- cor.test(relevant_data\(Safety_Rating, as.numeric(factor(relevant_data\)Experience)))
print(correlation) filtered_data <- data[data$Race %in% c(“Black”, “Latinx”, “White”), ]
average_safety <- aggregate(data\(`Do you feel safe at SU? Rate on a scale of 1-5 (1 being you DON'T feel safe, 5 being you feel safe)`, by = list(Race = data\)Race), FUN = mean)
print(average_safety)
ggplot(average_safety, aes(x = Race, y = x)) + geom_bar(stat = “identity”, fill = “skyblue”) + labs(x = “Race”, y = “Average Safety Rating”, title = “Average Safety Rating by Race”) + theme_minimal()
#An interactive plot graph that shows the answers given in the column “What has your experience at Albers/SU been like?” when hovering over it. but make the x axis the rating/column name “Do you feel safe at SU? Rate on a scale of 1-5 (1 being you DON’T feel safe, 5 being you feel safe)” and the y axis “Race” that uses all the responses given # Load necessary libraries library(plotly) library(readxl)
data <- read_excel(“Open Discussion for BLCC (Responses).xlsx”)
plot <- plot_ly(data = data, x = data\(`Do you feel safe at SU? Rate on a scale of 1-5 (1
being you DON'T feel safe, 5 being you feel safe)`, y =
data\)Race, text =
data$What has your experience at Albers/SU been like?, type
= ‘scatter’, mode = ‘markers’, marker = list(size = 10))
plot <- plot %>% layout(title = “Relationship between Feeling of Safety, Race, and Experience at Albers/SU”, xaxis = list(title = “Feeling of Safety at SU”), yaxis = list(title = “Race”))
plot
#rows 20-34
library(plotly) library(readxl)
data <- read_excel(“Open Discussion for BLCC (Responses).xlsx”)
selected_data <- data[20:34,]
plot <- plot_ly(data = selected_data, x =
~Do you feel safe at SU? Rate on a scale of 1-5 (1 being you DON'T feel safe, 5 being you feel safe),
y = ~Race, text =
~What has your experience at Albers/SU been like?, type =
‘scatter’, mode = ‘markers’, marker = list(size = 10))
plot <- plot %>% layout(title = “Relationship between Feeling of Safety, Race, and Experience at Albers/SU”, xaxis = list(title = “Feeling of Safety at SU”), yaxis = list(title = “Race”))
plot