Recently discovered the amazing knitr
library in R, which looks great when viewed in the viewer
. But unfortunately, the style gets lost when saved to an html file.
Code
library(knitr)
library(kableExtra)
some.table <-
data.frame (
x = rep(1,3),
y = rep(1,3)
)
some.table
x <- kable(some.table, format = "html") %>
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
x
file <- file('test.html')
write(x, file)
Table in viewer
https://i.sstatic.net/grSek.png
Table in browser
https://i.sstatic.net/I3o5d.png
How can I export the table with the same style to a html file? Note that I have more data in the html file, so I should be able to append it.
Response to comment(s)
User: @Hao
Using 'inspect element'
in Rstudio viewer reveals a link to a stylesheet:
https://i.sstatic.net/5mfqb.png
However, the code in this stylesheet seems to be quite large at 582,298
characters.