Search code examples
rformattable

How can i add a black boder to a formattable object in R?


I am trying to add a black border to a formattable object.

Here is my example table:

df <- data.frame(A = "SSF", B = 100, C = 75, Diff = 100 - 75)

formattable(df, align = c("l", "c", "c",  "r"))

Actual output:

Actual output:

Desired output: Desired output


Solution

  • You can specify the style in the table.attr argument inside the formattable function.

    formattable(df, align = c("l", "c", "c", "r"),
                            table.attr = 'style="border: 7px solid black;";\"')
    

    enter image description here