I'm currently trying to get counts of observations that meet multiple criteria using dplyr, and group by city. For example:
datacount.by.city <- data %>%
group_by(city) %>%
filter(cond1 == TRUE | cond2 == TRUE) %>%
tally()
I'm appending this condition to existing dataframe with a greater number of cities than is contained in these data. Is there a way to group_by(city) in this code while adding NA values for cities that are in my main dataframe but not in the data that I'm working on, so I can easily cbind to it and have the right number of columns in the right place?
left_join
. I personally really like the rstudio.com/wp-content/uploads/2015/02/… – tjebo