When using the WriteData or WriteDataTable commands from Openxlsx, the table I create using the aggregate command should be ported perfectly into Excel. All rows and columns should appear, and in roughly the same manner as they show up in R.
For example, in order to check the number of participants of each race according to the condition they were assigned, a table using aggregate(race,by=list(condition1,2,3),FUN=summary.factor) should return a table with 3 conditions, and have all three race factor levels broken down accordingly.
Actual Behavior
The created table shows up perfectly in R, but when it is exported into Excel only the first factor level shows up.
In my race table example, only Race factor level 1 appears as "x". RStudio displays x2 and x3, but this information never gets ported to Excel and is missing in the Excel table.
Steps to Reproduce the Problem
(please attach an example xlsx file if possible)
Use an aggregate command on a data frame to pull together an organized list/table, and assign this command a name (e.g. "Table 1") so it can be exported. Whatever you aggregate should have more than one factor level (e.g. "Race"; contains "White", "Black", "Other"). Note that changing the factor to a vector of strings did not solve the problem.
Use WriteData or WriteDataTable command to write the above created "Table 1" into an excel sheet
Expected Behavior
When using the WriteData or WriteDataTable commands from Openxlsx, the table I create using the aggregate command should be ported perfectly into Excel. All rows and columns should appear, and in roughly the same manner as they show up in R.
For example, in order to check the number of participants of each race according to the condition they were assigned, a table using aggregate(race,by=list(condition1,2,3),FUN=summary.factor) should return a table with 3 conditions, and have all three race factor levels broken down accordingly.
Actual Behavior
The created table shows up perfectly in R, but when it is exported into Excel only the first factor level shows up.
In my race table example, only Race factor level 1 appears as "x". RStudio displays x2 and x3, but this information never gets ported to Excel and is missing in the Excel table.
Steps to Reproduce the Problem
(please attach an example xlsx file if possible)
Use an aggregate command on a data frame to pull together an organized list/table, and assign this command a name (e.g. "Table 1") so it can be exported. Whatever you aggregate should have more than one factor level (e.g. "Race"; contains "White", "Black", "Other"). Note that changing the factor to a vector of strings did not solve the problem.
Use WriteData or WriteDataTable command to write the above created "Table 1" into an excel sheet
3.filenamehere.xlsx
sessionInfo()