This is what I want
Here is my code following Clemens post
library(magrittr)
sample1$sentence %<>%
stringr::str_replace_all(c('red' = '<span style="background- color:blue">red</span>'))
sample1 %>%
tableHTML()
Can anyone please help? Thanks.
This is what I want
Here is my code following Clemens post
library(magrittr)
sample1$sentence %<>%
stringr::str_replace_all(c('red' = '<span style="background- color:blue">red</span>'))
sample1 %>%
tableHTML()
Can anyone please help? Thanks.
Copyright © 2021 Jogjafile Inc.
The packages used:
The sample data:
Create a list to store words and the colour you want to apply to them:
The function below uses the
word_colour
, looks for the word in the sentence and adds aspan
around it with inlineCSS
that changes the font colour.You can then chain it all together. Important note:
rowwise
allows you to go through the data row by row.do()
is used as a general purpose manipulation function.The result is: