简体   繁体   English

从R创建Excel数据透视表

[英]create excel pivot tables from R

I am performing a number of data transformations within R. My manager wants the output to be an excel export with an excel pivot table, with all the features that an excel pivot table offers (such as double clicking to see data makeup). 我正在R中执行许多数据转换。我的经理希望输出是具有excel数据透视表的excel导出,并具有excel数据透视表提供的所有功能(例如双击以查看数据构成)。 Does anyone know of a way to create excel pivot tables from R? 有谁知道从R创建excel数据透视表的方法吗? I'm currently considering running VBA code through R just to create that pivot table; 我目前正在考虑通过R运行VBA代码只是为了创建数据透视表。 but I wanted to know what others think. 但我想知道别人的想法。 Thanks! 谢谢!

I came up with a unique solution in case anyone else needs to do this. 万一其他人需要这样做,我想出了一个独特的解决方案。 I create a excel template workbook ahead of time (this can be reused over and over). 我提前创建了一个excel模板工作簿(可以一遍又一遍地重复使用)。 I have the pivot table look for a specific named table. 我让数据透视表查找特定的命名表。 Then from R, I load in the excel template workbook, load in my data from R into excel using openxlsx. 然后从R中,我加载excel模板工作簿,使用openxlsx从R中将数据加载到excel。 I use openxlsx's feature to create a named data table; 我使用openxlsx的功能来创建命名数据表。 naming it the name the pivot table looks for. 将其命名为数据透视表要查找的名称。 Then I save the excel file as a new file. 然后,我将excel文件另存为新文件。 The pivot table is automatically populated from the data table. 从数据表中自动填充数据透视表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM