Conditionally formatting tables using gridExtra in R

岁酱吖の 提交于 2019-12-06 15:25:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/11432836/conditionally-formatting-tables-using-gridextra-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!