3
votes

I am new to R and R markdown, and was wondering how to make a nice table in an html file. I am trying to use ascii, but when I enter the code below I get a table that looks okay in an R console window, but looks bad in the html. I am pretty sure that the table is too wide, but I am not sure, it is 15 columns of 11 obs. Any help would be appreciated and I can add more information if I am not being clear.

print(ascii(FINALTABLE), type = "org", include.colnames = TRUE)
1
I think you need some css - scottyaz
type = "org" is for emacs org-mode are your sure that is really what you want - dickoa

1 Answers

7
votes

You can use the pander package to produce Rmarkdown compatible tables:

> library(pander)
> pandoc.table(head(iris[, 1:3]), style="rmarkdown")


|  Sepal.Length  |  Sepal.Width  |  Petal.Length  |
|:--------------:|:-------------:|:--------------:|
|      5.1       |      3.5      |      1.4       |
|      4.9       |       3       |      1.4       |
|      4.7       |      3.2      |      1.3       |
|      4.6       |      3.1      |      1.5       |
|       5        |      3.6      |      1.4       |
|      5.4       |      3.9      |      1.7       |