Saving Notebook Table Format when Knitting

In R Notebooks, when printing an object, Notebook will display data.frame in a very simple and understandable way, with the ability to scroll. However, when the document is knitted as an html output, Rmarkdown will display it in different ways. Two key features that I would like to capture in this table:

  • Column types / classes (symbol / coefficient / double, etc.)
  • If the column contains a list structure, the reference data class in that column

Any code that I can add in front of the object to get the same functions as in the R Notebook?

Below is an example:

ldata <- 26
xts_list <- replicate(ldata,xts(rnorm(ldata),order.by = seq(Sys.Date(),Sys.Date() + 25,1)),simplify = FALSE)

tibble(A = LETTERS,
   B = 1:ldata,
   C = letters,
   D = rnorm(ldata),
   E = colors()[1:ldata],
   F = sample(month.abb,ldata,replace = TRUE),
   G = xts_list)

Output to R Notebook when starting a block:

enter image description here

+4
source share
1 answer

, . html, , R, - DT:

library(DT)
datatable(cars)

Rmd, :

enter image description here

+3

Source: https://habr.com/ru/post/1674553/


All Articles