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")
Here is what I have under Tab 2
df <- read.csv("//apporto.com/dfs/LOYOLA/Users/briely_loyola/Desktop/2023 to date.csv")
#head(df)
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 ))
#DistrictCount
#compute the values of the top 10
DistrictCount<-DistrictCount[order(DistrictCount$n, decreasing = TRUE),]
result = DistrictCount[1:10,]
df_reasons <-count(df, DISTRICT)
#head(df_reasons)
df_reasons <- df_reasons[order(df_reasons$n,decreasing = TRUE),]
top_reasons <- df_reasons$DISTRICT[1:10]
#top_reasons
new_df <- df %>%
filter(DISTRICT %in% top_reasons)%>%
select(MONTH,DISTRICT)%>%
group_by(DISTRICT,MONTH)%>%
summarise(n=length(DISTRICT),.groups = 'keep')%>%
data.frame()
#head(new_df)
agg_tot <-new_df %>%
select(DISTRICT,n) %>%
group_by(DISTRICT) %>%
summarise(tot = sum(n),.groups = 'keep')%>%
data.frame()
#agg_tot
library(RColorBrewer)
library(ggthemes)
library(plyr)
#str(new_df)
new_df$MONTH<-as.factor(new_df$MONTH)
ggplot(new_df, aes(x = reorder(DISTRICT,n,sum), y =n,fill = MONTH ))+
geom_bar(stat="identity")+
coord_flip()+
labs(title="Number of Crimes by Districts in Boston", x="Districts in Boston", y = "Number of Crimes")+
theme_light()+
theme(plot.title=element_text(hjust=0.5))+
scale_fill_brewer(palette = "Paired")+
geom_text(data=agg_tot, aes(x=DISTRICT,y = tot, label=tot, fill=NULL),hjust=-0.1)+
scale_y_continuous(labels=comma, limits = c(0,25000))
Here is what I have under Tab
Here is what I have under Tab
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