First of all, I am using the ukpolice
package. We needed to select data from a specific city for 5 months, this dataframe is called crimes
.
Now, we need to create a new dataframe that contains the columns: category
, month
and number
.
The columns category and month already exist, but the column number still needs to be created. We are supposed to do this using the dplyr functions.
I created a frequency table using:
number_crime_type <- table(crimes$category)
In this table, the frequency per crime is established.
But I don't understand how I can create a new column in which the number of the crime is mentioned.
I'm really a rookie with R, so I really don't understand a lot of it.
How can I create a column that entails the number of the crime and add this column to the new dataframe?