Learn R Programming

compareGroups (version 4.9.0)

export2latex: Exporting descriptives table to LaTeX format

Description

This function takes the result of createTable and exports the tables to LaTeX format.

Usage

export2latex(x, ...)
# S3 method for createTable
export2latex(x, file, which.table = 'descr', size = 'same', 
    nmax = TRUE, nmax.method = 1, header.labels = c(), caption = NULL, 
    loc.caption = 'top', label = NULL, landscape = NA, colmax = 10, ...)
# S3 method for cbind.createTable
export2latex(x, file, which.table = 'descr', size = 'same', 
    nmax = TRUE, nmax.method = 1, header.labels = c(), caption = NULL, 
    loc.caption = 'top', label = NULL, landscape = NA, colmax = 10, ...)

Value

List of two possible components corresponding to the code of 'descr' table and 'avail' table. Each component of the list is a character corresponding to the LaTeX code of these tables which can be helpful for post-processing.

Arguments

x

an object of class 'createTable'.

file

Name of file where the resulting code should be saved. If file is missing, output is displayed on screen. Also, another file with the extension '_appendix' is written with the available data table.

which.table

character indicating which table is exported. Possible values are 'descr', 'avail' or 'both' (partial matching allowed), exporting descriptives by groups table, availability data table or both tables, respectively. Default value is 'descr'.

size

character indicating the size of the table elements. Possible values are: 'tiny', 'scriptsize', 'footnotesize', 'small', 'normalsize', 'large', 'Large', 'LARGE','huge', 'Huge' or 'same' (partial matching allowed). Default value is 'same' which means that font size of the table is the same as specified in the main LaTeX document.

nmax

logical, indicating whether to show the number of subjects with at least one valid value across all row-variables. Default value is TRUE.

nmax.method

integer with two possible values: 1-number of observation with valid values in at least one row-variable; 2-total number of observations or rows in the data set or in the group. Default value is 1.

header.labels

see the 'header.labels' argument from createTable.

caption

character specifying the table caption for descriptives and available data table. If which.table='both' the first element of 'caption' will be assigned to descriptives table and the second to available data table. If it is set to "", no caption is inserted. Default value is NULL, which writes 'Summary descriptives table by groups of 'y'' for descriptives table and 'Available data by groups of 'y'' for the available data table.

label

character specifying the table label for descriptives and available data table. This may be useful to cite the tables elsewhere in the LaTeX document. If which.table='both' the first element of 'label' will be assigned to descriptives table and the second to available data table. Default value is NULL, which assigns no label to the table/s.

loc.caption

character specifying the table caption location. Possible values are 'top' or 'bottom' (partial matching allowed). Default value is 'top'.

landscape

logical indicating whether the table must be placed in landscape, or NA that places the table in landscape when there are more than 'colmax' columns. Default value is NA.

colmax

integer indicating the maximum number of columns to make the table not to be placed in landscape. This argument is only applied when 'landscape' argument is NA. Default value is 10.

...

currently ignored.

See Also

createTable, export2csv, export2html, export2pdf, export2md, export2word

Examples

Run this code

if (FALSE) {
require(compareGroups)
data(regicor)
res <- compareGroups(sex ~. -id-todeath-death-tocv-cv, regicor)
export2latex(createTable(res, hide.no = 'n'), file=tempfile(fileext=".tex"))
}

Run the code above in your browser using DataLab