Background


This is a small R package that makes it easy for the user to produce a simple attractive looking table in a RMarkdown document. It is only intended for use when the output of the RMarkdown document is HTML.


There are many table packages out there that do lots of wonderful things. They all have merits. I think formattable by Kun Ren is going to be my favorite. I wrote this package to help me make some quick tables in RMarkdown that I found attractive and were better to look at for my collaborators than standard R output. Because it seems others are also interested in table output, then I thought I'd share.


Currently, I only have included one function tablecode that enables you to turn any dataframe into a table. Obviously, some common sense is needed in that your dataframe should be a reasonable number of columns and rows such that it would work in a table. There is no point trying to make a table out of 1000 columns and 1000 rows. I would recommend looking at packages like DT


Future Plans

Currently you can just make simple tables (i.e. no nested tables or split cells). I may extend it to be able to make those kind of tables. Also, the current option is just to pick one of the default themes. I have nearly finished making it such that you can modify the colors, borders, cell heights, font sizes etc. as you like to make tables that you like best.



Installation

You can install from github with devtools:

library(devtools)
devtools::install_github("jalapic/simpletable")



Using simpletable

Once you have a dataframe that you'd like to make into a table, simply use the function:


tablecode(df, tabletype="minimal")


You can pick from one of several default tabletypes - they are shown below. The critical thing is that this function must be written inside of a R chunk and you must have results='asis' as an option in your R chunk.


Current examples are shown below - note that some change color / font weight as you hover over them:


library(simpletable)

tablecode(paintings, tabletype="minimal")



tablecode(paintings, tabletype="hoverTable")



tablecode(paintings, tabletype="box")



tablecode(paintings, tabletype="onecol")



tablecode(paintings, tabletype="flattable3")



tablecode(paintings, tabletype="zebra")



tablecode(paintings, tabletype="zebra1")



tablecode(paintings, tabletype="gridtable")



tablecode(paintings, tabletype="another")



tablecode(paintings, tabletype="simple")



Feedback

I'd welcome feedback or comments. I don't have much time to work on this - I'm really just doing it for fun, but I'd like to hear from anyone who likes/dislikes it.

My email is jc3181 AT columbia DOT edu but it might be easier to get in touch on twitter here or on my github page here.




jalapic/simpletable documentation built on May 18, 2019, 11:18 a.m.