Last active
August 7, 2018 11:28
-
-
Save pboesu/38e7fa95bd2f81a7ee684eb3c7ee10d6 to your computer and use it in GitHub Desktop.
Jenni's coding challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(dplyr) | |
nuts1 <- readr::read_csv('NUTS1_kmsq.csv') | |
nuts1 %>% group_by(ONEKMREF) %>% summarise(biggest_area = max(kmsq_Area), biggest_area_index = which.max(kmsq_Area), biggest_area_name = Region_name[biggest_area_index] ) -> solution_df | |
#check for areas with multiple regions | |
nuts1 %>% group_by(ONEKMREF) %>% summarise(n_rows = n()) %>% arrange(desc(n_rows)) %>% head() | |
#check result | |
nuts1 %>% filter(ONEKMREF == 'NU2613') %>% select(ONEKMREF, Region_name, kmsq_Area) | |
solution_df %>% filter(ONEKMREF == 'NU2613') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment