Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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). Does anyone know of a way to create excel pivot tables from R? I'm currently considering running VBA code through R just to create that pivot table; but I wanted to know what others think. Thanks!

like image 498
mutaween464 Avatar asked Dec 18 '22 18:12

mutaween464


1 Answers

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). 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. I use openxlsx's feature to create a named data table; naming it the name the pivot table looks for. Then I save the excel file as a new file. The pivot table is automatically populated from the data table.

like image 149
mutaween464 Avatar answered Jan 02 '23 20:01

mutaween464