Skip to content

Instantly share code, notes, and snippets.

@luisDVA
Last active June 28, 2021 19:57
Show Gist options
  • Save luisDVA/37da8310a4f7e7bac640783cb30cc139 to your computer and use it in GitHub Desktop.
Save luisDVA/37da8310a4f7e7bac640783cb30cc139 to your computer and use it in GitHub Desktop.
Letter case
## %######################################################%##
# #
#### Letter case - your turn ####
# #
## %######################################################%##
# Import the Marine Protected Areas dataset (MPAS-your.csv)
# Summarize the number of Marine Protected Areas by country (Country full).
# load packages -----------------------------------------------------------
library(readr)
library(stringr)
library(dplyr)
library(unheadr)
library(janitor)
library(snakecase)
# import data -------------------------------------------------------------
MPAs <- read_csv("data/MPAS-your.csv") %>%
mash_colnames(1) %>%
clean_names()
# clean strings and summarize ---------------------------------------------
MPAs %>%
mutate(country_full = to_title_case(country_full, parsing_option = 0)) %>%
count(country_full, name = "number_of_MPAS", sort = TRUE) %>%
na.omit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment