I do have a specific question regarding the write.xlsx()
function of the xlsx
package in R.
I do have a matrix containing outputs of panel data regressions. For convenience I do want to export these outputs to a .xlsx file to include it in a Word document. However, when I do export the matrix via write.xlsx
the column names are automatically edited to the syntactically valid style with no symbols other than points, letters and numbers. So, the column vector of the matrix
table_columns <- c("Estimate (All periods)", "", "s.e. (All periods)", "Estimate (Periods 0 & 1)", "", "s.e. (Periods 0 & 1)")
(""
are empty column names because these columns contain star indicators for p-values)
becomes
Estimate..All.periods.|V2|s.e...All.periods.|Estimate..Periods.0...1.|V5|s.e...Periods.0...1.
Is there a way to suppress this reformatting such that I do not need to edit the .xlsx file after output?
-Edit- to make things easier to understand:
I do have a vector table_rows
with
c("All periods", " Std. error (All periods)", "Periods 0 & 1", " Std. error (Periods 0 & 1)")
and a vector table_columns
with c("(1) 1AM - 6AM", "", "(2) 6AM - 10AM", "", "(3) 10AM - 6PM", "", "(4) 6PM - 10PM", "", "(5) 10PM - 1AM", "", "(6) Daily", "")
These are used to set the dimnames of the matrix table
with matrix(c(table_1, table_1p, table_2, table_2p, table_3, table_3p, table_4, table_4p, table_5, table_5p, table_6, table_6p), 4, 12, dimnames = list(table4_rows, table4_columns))
where table_odd
and table_oddp
denote the column vectors containing estimantes and their p-level indicators and table_even
the standard errors in parantheses. All vectors are of type chr
I do run write.xlsx(table, paste0(getwd(), "/results.xlsx"), sheetName = "Results")
to convert the matrix to .xlsx