delim.table tries to format its first argument into one or more tables
that will be displayed in another application. The most common use is to
produce a CSV style file that can be imported into a spreadsheet. The default
values for delim and eor should be adequate for this, and all the
user has to do is to supply a filename as in the first example. When a filename
is provided, the function attempts to open the file, write its output to it and
close it again. In order to deal with the multilevel lists that are often
produced by other functions, the function calls itself until it reaches the
lowest level of the list, where it can successfully format the contents. Thus
the function only passes the connection, not the filename, in recursive calls.
If the user passes both a filename and a valid connection, the output will be
written to the connection and the filename will not be used.
delim.table will fail if passed a table with more than two dimensions.
However, the function will process 2D "slices" of such tables if called with
one of the apply family of functions or manually for each slice.
delim.table can also be used to format HTML tables as in the second
example. If the user wants different tags from the defaults, pass these
explicitly. In principle, any markup language that can produce a table using
commands that include; commands to begin and end the table, a command to
start and end a row, and a command to start a new cell.
delim.table is consistent with the default CSV arguments, adding an
extra delimiter to the first line if there are row names. The user should set
leading.delim to FALSE for a table without the empty cell at the upper
left. When delim.table is used to format tables for htmlize, it
should not attempt to open a new connection.
An unexpected use of delim.table is producing tables that can be imported
into OpenOffice Writer and most other word processors. While the tables in an HTML
listing can be imported directly, the formatting is usually not suitable. If a
table is output to an HTML or text document formatted with TAB characters as the
delimiter as in the third example, the output can be copied and pasted into the
word processor document and then converted to a table.