Skip to content

Instantly share code, notes, and snippets.

@giacecco
Created July 25, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giacecco/7e608f4ffe5164beaadc to your computer and use it in GitHub Desktop.
Save giacecco/7e608f4ffe5164beaadc to your computer and use it in GitHub Desktop.
# 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