在R中使用gridExtra有条件地格式化表 [英] Conditionally formatting tables using gridExtra in R

查看:1114
本文介绍了在R中使用gridExtra有条件地格式化表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我接触到R中的包 gridExtra 中的 grid.table 函数。使我的数据框看起来比单纯地将它们打印到控制台上更好。



默认设置工作得很好,但是现在我变得贪婪了。我在寻求帮助,因为我不确定以下两种格式设置是否可能。我阅读了文档,但仍然不确定是否会发生这种情况...


  1. 有条件地格式化/高亮显示行和列标准。我的想法是,我可以突出显示某一行,使其从表格的其余部分突出显示。

  2. 是否可以左击表格中的第一列并居中对齐


    简单来说,我真的很喜欢将一个数据框格式化为一张表格,但现在我希望能够做到一些额外的格式化技术,以获得表所需的位置。

    解决方案

    刚刚发送电子邮件Baptiste的作者 gridExtra ,该功能目前不可用。不过,他表示,一旦 gtable 包正式发布,他正在计划更新网格。表格应该使定制输出更容易。但也说不要屏住呼吸...他也建议随意使用源代码,并适应它。



    但我也一直在寻找用于突出显示表中的行并使用 dprint 来执行此操作的方法。希望有帮助。


    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.

    解决方案

    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.

    这篇关于在R中使用gridExtra有条件地格式化表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆