R shiny data table content with html tags -
i have data table in column a
character field. need make strings withing column appear different color(just beginning, need search , replace multiple strings different colors ultimately). i'm attempting following way unsuccessful.
below i'm attempting put html tags within column values, i'm not sure how make browser treat html tags while displaying data table. ideas?
library(shiny) library(dt) x<-data.table(a=c("srinivas asfsis asdfsadf","vassri asdf asdfasdf","csdasdsriasfasf")) x$a<-as.data.table(sapply(x$a,function(x)gsub("sri",'<strong style="color:red">sri</strong>',x))) shinyapp( ui = datatableoutput("table1"), server = function(input, output) { output$table1<-renderdatatable({ datatable(x) }) } )
you've got conflicting packages each have functions same name. doesn't appear need more shiny
package this...
library(shiny) x<-data.frame(a=c("srinivas asfsis asdfsadf","vassri asdf asdfasdf","csdasdsriasfasf")) x$a<-gsub("sri",'<strong style="color:red">sri</strong>',x$a) shinyapp( ui = fluidpage(shiny::datatableoutput("table1")), server = function(input, output) { output$table1<-shiny::renderdatatable(x, escape=false) } )
Comments
Post a Comment