Skip to content

Instantly share code, notes, and snippets.

View luisDVA's full-sized avatar

Luis Verde Arregoitia luisDVA

View GitHub Profile
## %######################################################%##
# #
#### Parsing numbers - your turn ####
# #
## %######################################################%##
# Import the Marine Protected Areas dataset (MPAS-mine.csv)
# Subset to keep only the MPA names and columns with extent data
# Make the columns that hold the MPA extent into usable numeric variables
# Watch out for decimals
@luisDVA
luisDVA / common-issues-08_empty-rows-columns.R
Last active January 12, 2021 22:38
Empty rows and colums
## %######################################################%##
# #
#### Empty rows and columns - your turn ####
# #
## %######################################################%##
# Import the Marine Protected Areas dataset (MPAS-your.csv)
# Identify the empty rows and columns, and create a new object with only the empty rows and columns
# Remove the empty rows and columns
## %######################################################%##
# #
#### Broken values - your turn ####
# #
## %######################################################%##
# Load the raw Age of Empires units dataset from csv (aoe_raw.csv)
# Identify the broken values in both the 'Type' and 'Name' columns and unbreak them
# Clean up any separator-related issues arising from the 'unbreaking'
## %######################################################%##
# #
#### Duplicates - your turn ####
# #
## %######################################################%##
# Load the messy Age of Empires units dataset bundled with `unheadr` (AOEunits_raw)
# Keep only units of Type "Cavalry"
# Identify duplicated records across all variables
# Remove duplicated records across all variables
## %######################################################%##
# #
#### Compound values - your turn ####
# #
## %######################################################%##
# Import the Marine Protected Areas dataset (MPAS-your.csv)
# Separate the country codes variable (ISO3 and UN scheme)
# Unnest the Reference variable
# > Keep an eye on the separators
@luisDVA
luisDVA / common-issues-04_emb-subheaders.R
Created November 25, 2020 20:10
Missing, implicit, or misplaced grouping variables
## %######################################################%##
# #
#### Missing, implicit, or misplaced ####
#### grouping variables - your turn ####
# #
## %######################################################%##
# Load the `primates2017` dataset bundled with 📦 `unheadr`
# Create a new column that groups the different species by taxonomic family.
# In biology, taxonomic families all end in the suffix "_DAE_"
## %######################################################%##
# #
#### Letter case - your turn ####
# #
## %######################################################%##
# Import the Marine Protected Areas dataset (MPAS-your.csv)
# Summarize the number of Marine Protected Areas by country (Country full).
## %######################################################%##
# #
#### Whitespace - your turn ####
# #
## %######################################################%##
# - Import the Marine Protected Areas data (MPAS-your.csv) from the previous lesson
# - check the Country variable for leading or trailing whitespace
# - Remove it if necessary.
## %######################################################%##
# #
#### Unusable variable names - your turn ####
# #
## %######################################################%##
# - Import the Marine Protected Areas data (MPAS-your.csv)
# - Make the variable names usable by placing all header fragments in a single
# header row
# - Clean the names for consistency
@luisDVA
luisDVA / regex-02_regex-4-data-cleaning.R
Created November 24, 2020 20:54
Regex for data cleaning
## %######################################################%##
# #
#### Regex for data cleaning - your turn ####
# #
## %######################################################%##
# 1. Download CRAN package descriptions
# 2. Select Package name, author, description, and all variables that end in 'ports'
# 3. Filter rows for packages with names that:
# - end in plot