Skip to content

Instantly share code, notes, and snippets.

@darokun
Created March 23, 2022 09:33
Show Gist options
  • Select an option

  • Save darokun/c1f10bb7c8160ead3df904784cbeb6d8 to your computer and use it in GitHub Desktop.

Select an option

Save darokun/c1f10bb7c8160ead3df904784cbeb6d8 to your computer and use it in GitHub Desktop.
# PLASMID - abbreviations script
# install.packages("tidyverse") # run only if not previously installed
# install.packages("googlesheets4") # run only if not previously installed
library(tidyverse)
library(googlesheets4)
gs4_deauth() # deactivate authorization mode so it doesn't ask for google sign-in. Useful when only reading data
# read data
abb <- read_sheet("https://docs.google.com/spreadsheets/d/1ePlZC0FmFuqiq0B59wtNu4RCDEgypn_ucyBzFb8oK0g/edit#gid=0")
# get a vector of abbreviations, with a comma and a space at the end of each term, and arranged in alphabetical order A-Z
v_abbreviation <- abb %>%
mutate(abbreviation = str_c(abbreviation, ", ")) %>%
arrange(abbreviation) %>%
pull(abbreviation)
# get a vector of meanings, with a comma and a space at the end of each term, and arranged by abbreviations in alphabetical order A-Z
v_meaning <- abb %>%
mutate(meaning = str_c(meaning, "; ")) %>%
arrange(abbreviation) %>%
pull(meaning)
# concatenate both vectors
cat(paste0(v_abbreviation, v_meaning))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment