I am trying to merge data frames that I create in a loop via the rbind
function. I am pretty new to R so it is probably a rookie mistake. After creation of the list it seems to create a list of 5 chr's. And when I try to run the code it does not find any data since it does not loop properly through the dates.
dates <- list("2020-07", "2020-08", "2020-09", "2020-10", "2020-11")
crimes <- data.frame()
for(i in dates){
rbind(crimes,as.data.frame(ukc_crime_location(lat = 52.395355, lng = -1.492943, date = i)))
}
I think you may need crimes <-
to update crimes
in each iteration, e.g.,
for(i in dates){
crimes <- rbind(crimes,as.data.frame(ukc_crime_location(lat = 52.395355, lng = -1.492943, date = i)))
}