background color in data table

Hi!! I'm trying to make my DT background more transparent. I've my colours in hexadecimal, for example "@FF8700". I've read that in R we can set the alpha value for opacity with two more digits, for example : "@FF870099". If I try this with barplot, it works:

barplot(1,col="#FF8700")
barplot(1,col="#FF870099")

But when I try it with DT it doesn't work

datatable(ColumnasFact[columna%in%names(dt.fact)],
rownames= FALSE,
options = list(paging=FALSE, dom = 'tip',
columnDefs = list(list(visible=FALSE, targets=2))))%>%formatStyle(
'TipoVar',
target = "row",
backgroundColor =styleEqual(c("bas","esp","atr","opc"),c("#FF870099","#FF9C00","#FFB200","#FFC700"))
)

1 Like

DT is an R interface to the DataTables javascript library, so for more advanced styling the DT documentation directs you to the DataTables API (the table is ultimately rendered in HTML and CSS).

That said, it's hard to reproduce what you're describing right now. Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.reprex("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ, linked to below.

Thanks!

I've noticed that opening with the R-studio browser the color doesn't appears, but opening it whit a browser i.e. chrome the colors are well showed.

1 Like

I wonder if translucency support in the Viewer pane might be improved with the RStudio 1.2 Preview? It's got a new Chromium-based rendering engine, so CSS rendering would hopefully be closer to Chrome's.

1 Like