Jessica Minnier 2019-05-10
tibble::enframe()
converts a named vector to a tibble andtibble::deframe()
does the oppositeforcats::fct_infreq()
reorders a character or factor column in place, and can be used in ggplot:
ggplot(mtcars %>% mutate(carb = as.character(carb)), aes(fct_infreq(carb),fill=carb)) + geom_bar()
stringr::str_detect
can be used to search for multiple strings in a vector by usingpaste
collapse:
fruit <- c("apple", "banana", "pear", "pinapple")
mystrings <- c("apple","pear","grape")
str_detect(fruit, paste(mystrings,collapse="|"))
#> [1] TRUE FALSE TRUE TRUE