I adapted a script to run the multiple (post-hoc) comparisons dunn.test
function from the dunn.test
package, on multiple variables, which generates multiple data frames, saved with the bellow (simplified) code in an .xls file as separate tables. What I want is to save with the each date frame also the name of variable (column) that was analyzed, as table titles (not column titles). I am looking for a solution for several hours, but without success. How to do this? They are too many and I do not want to enter them manually.
wb <- createWorkbook()
sheet <- createSheet(wb, sheetName="Sheet1")
# start analyzing data in a for loop here
# and add created data frames to a sheet
addDataFrame(mydataframe, sheet)
# end loop here
saveWorkbook(wb, "myfile.xls", sep="")
You could convert your source data.frame to a text matrix, prefix whatever title you want, and write that to file.
For example, given this data.frame:
You could use a function like this:
Then you can call the function and write the output to file (using write.table or one of the xls conversion packages if you must).
The result, opened in Excel, is this: