Here is an intro section
Here is something about my data
Here is some text
Here is what I have under Tab 1
df <- read.csv("//apporto.com/dfs/LOYOLA/Users/briely_loyola/Desktop/2023 to date.csv")
library(dplyr)
library(DescTools)
library(ggplot2)
library(data.table)
library(scales)
# count the number of criminal offensives in each district
DistrictCount <- data.frame(count(df,DISTRICT ))
#compute the values of the top 10
DistrictCount<-DistrictCount[order(DistrictCount$n, decreasing = TRUE),]
result = DistrictCount[1:10,]
# set up a way to label each bar in the bar graph
values = result$n
# create bar graph
ggplot(DistrictCount[1:10,], aes(x =reorder(DISTRICT,-n),y = n ))+
geom_bar(colour ="darkblue", fill="lightblue", stat = "identity")+
labs(title = "Number of Crimes in Boston Districts (Top 10)", x = "District", y = "Number of Incidents")+
theme(plot.title=element_text(hjust = 0.5))+
geom_text(aes(label = values),vjust= -0.5,color="black")
library(dplyr)
library(ggplot2)
library(ggthemes)
#shootings
top_shootins <- count(df,DAY_OF_WEEK)
#observe count
#top_shootins
shooting_df <- df %>%
select(SHOOTING, DAY_OF_WEEK) %>%
mutate(ShotsFired = ifelse(SHOOTING == "1", "Shooting", ifelse(SHOOTING == "0", "No Shooting", "Nothing Reported"))) %>%
group_by(DAY_OF_WEEK, ShotsFired) %>%
summarise(n=length(ShotsFired), .groups = 'keep') %>%
group_by(DAY_OF_WEEK) %>%
mutate(percent_of_total= round(100*n/sum(n),1))%>%
ungroup()%>%
data.frame()
#observe data
#shooting_df
#Test data
#shooting_df[shooting_df$DAY_OF_WEEK == "Wednesday",]
#view structure
#str(shooting_df)
ggplot(data = shooting_df, aes(x="", y=n, fill=ShotsFired)) +
geom_bar(stat = "identity", position = "fill") +
coord_polar(theta = "y", start = 0) +
labs (fill = "Days", x = NULL, y = NULL, title = "Percentage of Crime that Involve Guns by Day") +
theme(plot.title = element_text(hjust = 0.5),
axis.text = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank()) +
facet_wrap(~ DAY_OF_WEEK, ncol = 4, nrow = 2) +
scale_fill_brewer(palette = "Reds") +
geom_text(aes(x = 1.7, label = paste0(percent_of_total,"%")),
size = 2,
position = position_fill(vjust = 0.5))
Here is what I have under Tab
Here is what I have under Tab
We are now done with charts
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:
1+1