R knitr - kable table html formatting for small text -


i trying format table in r markdown (compiling html) using knitr::kable small possible. perhaps making text smaller example. googling around lot have figured out how control these individual elements, table stays same size. thought should smaller elements required less space, did not happen.

so else have set make table smaller?

here code:

--- title: "kable table formating" output: html_document --- <style type="text/css"> <!--   td{     font-family: arial;      font-size: 4pt;     padding:0px;     cellpadding="0";     cellspacing="0"   }   th {     font-family: arial;      font-size: 4pt;     height: 20px;     font-weight: bold;     text-align: right;     background-color: #ccccff;   }   table {      border-spacing: 0px;     border-collapse: collapse;   } ---> </style>  ```{r echo=t} library(knitr,quietly=t)  n <- 14 m <- runif(n*n) dim(m) = c(n,n) df <- data.frame(m) kable(df,padding=0) ```   

and here output - don't need whitespace:

enter image description here

you need add format="html" kable call , you'll have it. default, kable produces code markdown table (compare results of kable(df) , kable(df, format = "html")

```{r echo=t} library(knitr,quietly=t)  n <- 14 m <- runif(n*n) dim(m) = c(n,n) df <- data.frame(m) kable(df, format = "html", pad=0) ``` 

which looks this:

enter image description here


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -