Skip to content

Instantly share code, notes, and snippets.

@chelseaparlett
Created July 15, 2021 00:56
Show Gist options
  • Save chelseaparlett/755c0aa66c026629101dbed324d9b3c1 to your computer and use it in GitHub Desktop.
Save chelseaparlett/755c0aa66c026629101dbed324d9b3c1 to your computer and use it in GitHub Desktop.
#---libs---------------------------------------------------
library(ltm)
library(jsonlite)
library(tidyverse)
library(patchwork)
library(stargazer)
library(rstan)
library(brms)
library(viridis)
library(plotly)
library(DescTools) # gamma
library(bayesplot)
library(shinystan)
library(MASS) # polr
library(ordinal) # clmm
library(rstanarm)
library(beepr)
library(lme4)
library(zoib)
library(bayesplot)
library(patchwork)
library(qdap) #spellChecking
#---test code-------------------------------------------------
testStr <- "{\"Recall\":\"mold, steak , dread, cone, waist, tack, birch, rakem beast, spark,\\n\"}"
testFunc <- function(str){
x <- (gsub("\\{\\\"Recall\\\":\"", "", str) %>% #get rid of beginning of dict
gsub("\"\\}", "", .) %>% # get rid of end of dict
gsub("[\r\n]", " ", .) %>% # get rid of new lines
gsub("\\\\n", " ", .) %>% # get rid of double newline
gsub("[.;]", " ", .) %>% # get rid of periods, semicolons
tolower( ) %>% # to lower case
strsplit(., "\\, |\\,| ")) #split to get each word
return(x)
}
testFunc(testStr)
@bschneidr
Copy link

The R code works for me if I explicitly load magrittr with library(magrittr). I don't think magrittr gets loaded by any of the other packages in the list in lines 1-22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment