Conditionally formatting tables using gridExtra in R
Asked Answered
L

1

1

Recently I was exposed to the grid.table function in the package gridExtra in R. I am simply looking to make my dataframes look "better" than simply printing them to the console.

The default settings work pretty well, but now I am getting greedy. I am asking for help because I am not sure if the following two formatting settings are possible. I read the documentation but am still not sure if this can happen...

  1. Conditionally format/highlight rows and columns if they meet a certain criteria. My thinking was that I could highlight a certain row to make it stand out from the rest of the table.
  2. Is it possible to left alight the first column in the table and center align everything else?

In short, I really like how easy it is to format a dataframe as a table, but now I am hoping I can do a few extra formatting techniques to get the tables to where I need them to be.

Lardaceous answered 11/7, 2012 at 12:37 Comment(1)
Did you ever find your own solution to this?Adon
A
0

Having just emailed Baptiste the author of gridExtra, that functionality is not currently available.

However, he says that once the gtable package is officially released he is planning to make an update to grid.table which should make it easier to customise the output. But also says not to "hold your breath"...He also however suggested to feel free to use the source code and adapt it.

But I too have been looking for ways to highlight rows in tables and have used the package dprint to do so. Hope that helps.

Adon answered 26/7, 2012 at 23:44 Comment(2)
have a look at the comments on code.google.com/p/gridextra/wiki/tableGrob though, there's an earlier version that allowed some highlighting with grid.editEctosarc
here is the dprint solution to highlight rows...#11665062Adon

© 2022 - 2024 — McMap. All rights reserved.