Can anyone help me with finding a way how to calculate the most common occurring value from this example data frame i have created with dput().
structure(list(X = c("Camden", "Bromley", "Croydon", "Bromley",
"Croydon", "Camden"), Y = c("Theft", "Theft", "Theft", "Burglary",
"Theft", "Robbery")), class = "data.frame", row.names = c(NA,
In this data frame X represents The location, and Y represents the type of offence corresponding to that location.
My aim is to find out the most common offence for a particular type of location and then present the answer of that in a summary table. How can i go about doing this when I have thousands of data points?
For this example, of course the most common offence in croydon is theft. But how can I use code to find this answer.
p.s. I am a new user to R and have only had experience with tidyverse, dply and ggplot2.