Skip to content

Instantly share code, notes, and snippets.

@giacecco
Created Jul 25, 2015
Embed
What would you like to do?
# calculate how many postcodes per OA and add to above table
postcodes_per_oa <- properties_per_pcd %>% group_by(OA11CD) %>% summarise(postcodes_no = n())
properties_per_pcd <- left_join(properties_per_pcd, postcodes_per_oa, by = c("OA11CD" = "OA11CD"))
# calculate the number of properties per postcode as an even distribution vs the OA
properties_per_pcd$pcd_properties_no <- properties_per_pcd$oa_properties_no / properties_per_pcd$postcodes_no
# how many addresses in my postcode?
properties_per_pcd[properties_per_pcd$PCD7 == "HP4 3JD", c("PCD7", "pcd_properties_no")]
> properties_per_pcd[properties_per_pcd$PCD7 == "HP4 3JD", c("PCD7", "pcd_properties_no")]
PCD7 pcd_properties_no
678220 HP4 3JD 16
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment