text_number_replace <- function(x) {
require(tidyverse)
comp_tbl <- tibble(number = 1:10,
text = c('first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth'))
comp_test <- 1:nrow(comp_tbl)
tested_value <- tibble()
for (i in comp_test) {
new_test <- tibble(test = ifelse(str_detect(x,comp_tbl$text[i])==TRUE,comp_test[i],0))
tested_value <- bind_rows(tested_value,new_test)
}
tested_value <- tested_value %>%
filter(!test == 0)
value <- tested_value[['test']]
comp_fix <- comp_tbl %>%
filter(number == value)
new_x <- gsub(comp_fix$text,comp_fix$number,x)
return(new_x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.