I have a Excel spread sheet with which looks at the relationship between victim and offender in murders. Either the murderer know the victim or not.
I want to plot it in a barplot, but I need to group each year. I am a bit green in R graphing so I did a paint image of what I want to have in my report:
I have the following code:
# Libraries
library("readxl")
res <- readxl::read_excel("muders_in_norway_with_relations.xlsx", sheet = 1)
dput(head(res[, 1:3]))
# Plot bar
barplot(`Relation`~`2019`, res,
main = "Murders in Norway with relations",
xlab = "Year",
ylab = "Murders")
which outputs this:
## structure(list(Relation = c("Relations", "No relation"), `2019` = c(26,
## 3), `2020` = c(30, 1)), row.names = c(NA, -2L), class = c("tbl_df",
## "tbl", "data.frame"))
Maby I am doing something wrong when I am reading the data into R?


