Created
November 11, 2019 21:42
-
-
Save k5cents/848cd5cdc0d8de4872ebbb7fbd0e2dfd to your computer and use it in GitHub Desktop.
Code to replace emoji with markdown short code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(jsonlite) | |
library(tidyverse) | |
library(magrittr) | |
url <- "https://gist.githubusercontent.com/oliveratgithub/0bf11a9aff0d6da7b46f1490f86a71eb/raw/ac8dde8a374066bcbcf44a8296fc0522c7392244/emojis.json" | |
shortcodes <- | |
fromJSON(url) %>% | |
use_series("emojis") %>% | |
as_tibble() %>% | |
na_if("") %>% | |
arrange(as.numeric(order)) %>% | |
select(emoji, shortname) %>% | |
filter(!is.na(shortname)) | |
head(shortcodes) | |
ex <- "I'm so cool 😎 I can code!" | |
str_replace_all(ex, pattern = deframe(shortcodes)) |
Author
k5cents
commented
Nov 11, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment