I have a df named "crimes" with mutiple observations and columns(for instance: category, id, month, street_id, street_name) and I have to create a new df named "anti_social_behavior" where I should add the columns id, month and street_name from "crimes" when the category of the observation is "anti-social-behavior".
I don't know how to add the columns of "crimes" in the new df based on this condition, I'd highly appreciate your help.
My code so far is this:
anti_social_behavior <- data.frame()
for (i in 1:length(crimes)){
if (crimes[i,1] == "anti-social-behaviour"){
#this is the part of the code I am missing
}
}