Skip to content

Instantly share code, notes, and snippets.

@luisDVA
Last active January 12, 2021 22:41
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 luisDVA/733153802e7b6122d0c716df806ad129 to your computer and use it in GitHub Desktop.
Save luisDVA/733153802e7b6122d0c716df806ad129 to your computer and use it in GitHub Desktop.
Unusable headers
## %######################################################%##
# #
#### 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
# load packages -----------------------------------------------------------
library(readr)
library(unheadr)
library(dplyr)
library(janitor)
# import data -------------------------------------------------------------
MPAs <- read_csv("data/MPAS-your.csv")
# fix headers -------------------------------------------------------------
MPAs <- MPAs %>% mash_colnames(1) # warning can be ignored
# clean names -------------------------------------------------------------
MPAs <- MPAs %>% clean_names()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment