Skip to content

Instantly share code, notes, and snippets.

@trinker
Created December 13, 2017 03:40
Show Gist options
  • Select an option

  • Save trinker/79ca685f9b086c924e16385382c259a7 to your computer and use it in GitHub Desktop.

Select an option

Save trinker/79ca685f9b086c924e16385382c259a7 to your computer and use it in GitHub Desktop.
Find non-ascii chars in package's data
library(pacman); library(textshape)
lapply(p_data(lexicon)$Data, function(x){
m <- eval(parse(text=x))
if (is.atomic(m)) return(sum(grepl('[^ -~]', m)))
sum(sapply(as.data.frame(m), function(y) sum(grepl('[^ -~]', y))))
}) %>%
setNames(p_data(lexicon)$Data) %>%
textshape::tidy_list()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment