Skip to content

Instantly share code, notes, and snippets.

@aammd
Created February 24, 2017 16:26
Show Gist options
  • Save aammd/e85fd9a3140d7c590de9d9c9a421d580 to your computer and use it in GitHub Desktop.
Save aammd/e85fd9a3140d7c590de9d9c9a421d580 to your computer and use it in GitHub Desktop.
if you have species names in one column
library(dplyr)
library(tidyr)
library(stringr)
too_wide <- frame_data(
~common_name, ~plant_genera,
"Abagrotis apposita", "Amelanchier Arbutus Cenanothus",
"Abagrotis brunipennis", "Prunus Vaccinium"
)
too_wide %>%
mutate(plant_genera = str_split(plant_genera, " ")) %>%
unnest(plant_genera)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment