R: Exporting "data.frame" to an object of class "ztable"

ztable_sub {ztable} | R Documentation

## Exporting "data.frame" to an object of class "ztable"

### Description

Exporting "data.frame" to an object of class "ztable"

### Usage

    ztable_sub(x, family = NULL, size = 5, color = getOption("ztable.color",
      "black"), tablewidth = 0.3, type = getOption("ztable.type", "latex"),
      include.rownames = getOption("ztable.include.rownames", TRUE),
      placement = "!hbtp", position = "c",
      show.heading = getOption("ztable.show.heading", TRUE),
      show.footer = getOption("ztable.show.footer", TRUE), caption = NULL,
      caption.placement = getOption("ztable.caption.placement", "top"),
      caption.position = getOption("ztable.caption.position", "c"),
      caption.bold = getOption("ztable.caption.bold", FALSE), align = NULL,
      digits = NULL, display = NULL, sidewaystable = FALSE,
      longtable = FALSE, rotate = FALSE, turn = FALSE, angle = 0,
      wraptable = FALSE, wraptablewidth = 12, tabular = FALSE, label = NULL,
      hline.after = NULL, booktabs = getOption("ztable.booktabs", TRUE),
      prefix.rows = NULL, commands = NULL, top.command = NULL,
      zebra = getOption("ztable.zebra", NULL),
      zebra.color = getOption("ztable.zebra.color", NULL),
      zebra.type = getOption("ztable.zebra.type", 1),
      zebra.colnames = getOption("ztable.zebra.colnames", FALSE),
      zebra.rownames = getOption("ztable.zebra.rownames", TRUE),
      zebra.list = NULL, colnames.bold = getOption("ztable.colnames.bold",
      FALSE), include.colnames = getOption("ztable.include.colnames", TRUE),
      cgroup = NULL, n.cgroup = NULL, rgroup = NULL, n.rgroup = NULL,
      cspan.rgroup = NULL, pcol = NULL)

### Arguments

`x` | A data.frame
`family` | Font family. Default value is NULL. Possible value is one of the c("serif","times").
`size` | An integer from 1 to 10 indicating font size= c("tiny","scriptsize", "footnotesize","small","normalsize","large","Large","LARGE","huge","Huge") respectively. Defaulting is 5(= "normalsize").
`color` | A character indicating color of ztable
`tablewidth` | A numeric value indicating desired table width as a ratio to linewidth. This value is only useful when caption is longer than table length. Default value is 0.3.
`type` | character indicating formats of ztable, either "html" or "latex". Default value is "latex"
`include.rownames` | A logical value whether or not include rownames in the table Default value is TRUE.
`placement` | The table will have placement given by placement where placement must be NULL or contain only elements of "h","t","b","p","!","H". Default value is "!hbtp".
`position` | The table will be have placed at the center of the paper if position is "center" or "c", and at the left side of the paper if it equals "left" or "l", and at the right side of the paper if it equals "right" or "r". The position is translated to specific latex environments such as "flushright" or "flushleft" or "center" (provided as a character vector) will enclose the tabular environment. Default value is "center".
`show.heading` | A logical value whether or not include headings in the table. Default value is TRUE.
`show.footer` | A logical value whether or not include headings in the table. Default value is TRUE.
`caption` | A character
`caption.placement` | The caption will be have placed at the top of the table if caption.placement is "top" and at the bottom of the table if it equals "bottom". Default value is "top".
`caption.position` | The caption will be have placed at the center of the table if caption.position is "center" or "c", and at the left side of the table if it equals "left" or "l", and at the right side of the table if it equals "right" or "r". Default value is "center".
`caption.bold` | whether or not use bold font for caption
`align` | Character vector : nchar equal to the number of columns of the resulting table indicating the alignment of the corresponding columns.
`digits` | Numeric vector of length equal to one (in which case it will be replicated as necessary) or to the number of columns of the resulting table
`display` | Character vector of length equal to the number of columns of the resulting table indicating the format for the corresponding columns. Since the row names are printed in the first column, the length of display is one greater than ncol(x) if x is a data.frame. These values are passed to the formatC function. Use "d" (for integers), "f", "e", "E", "g", "G", "fg" (for reals), or "s" (for strings). "f" gives numbers in the usual xxx.xxx format; "e" and "E" give n.ddde+nn or n.dddE+nn (scientific format); "g" and "G" put x[i] into scientific format only if it saves space to do so. "fg" uses fixed format as "f", but digits as number of significant digits. Note that this can lead to quite long result strings. Default value is NULL. the class of x.
`sidewaystable` | Logical value whether or not set the tabular environment= "sidewaystable". Requires Latex "rotating" package in preamble. Default value is FALSE.
`longtable` | Logical value whether or not set the tabular environment= "longtable". Requires Latex "longtable" package in preamble. Default value is FALSE.
`rotate` | Logical value whether or not set the tabular environment= "rotate". No special arrangement is made to find space for the result. Requires Latex "rotating" package in preamble. If TRUE, requires the rotate angle(counterclockwise). Default value is FALSE.
`turn` | Logical value whether or not set the tabular environment= "turn". In this environment, Latex leaves space for the rotated table. Requires Latex "rotating" package in preamble. If TRUE, requires the rotate angle. Default value is FALSE.
`angle` | An integer indicate the angle to rotate(degree); range -180 to 180. Default value is 0.
`wraptable` | Logical value whether or not set the tabular environment= "wraptable". Requires Latex "wrapfig" package in preamble. Default value is FALSE.
`wraptablewidth` | A integer indicate wraptable width in centimeter. Default=12.
`tabular` | Logical value whether or not set the tabular environment. If TRUE, no tabular environment is set. Default value is FALSE.
`label` | Character vector of length 1 containing the LaTeX label or HTML anchor. Set to NULL to suppress the label. Default value is NULL.
`hline.after` | A vector of numbers between -1 and "nrow(x)", inclusive, indicating the rows after which a horizontal line should appear. If NULL is used no lines are produced. Default value is c(-1,0,nrow(x)) which means draw a line before and after the columns names and at the end of the table. Repeated values are allowed.
`booktabs` | Logical value. If TRUE, the toprule, midrule and bottomrule tags from the LaTex "booktabs" package are used rather than hline for the horizontal line tags. Requires Latex "booktabs" package in preamble. Default value is TRUE.
`prefix.rows` | A numeric vector contains the position of rows on which extra Latex commands should be added as a prefix.
`commands` | A character vector of the length 1 or same length of the nrow of data.frame which contains the command that should be added as a prefix at the specified rows. Default value is NULL, i.e. do not add commands.
`top.command` | A character vector of the length 1 which contains the command that should be added as a prefix at the colnames row.
`zebra` | Null or an integer of 0 or 1 or 2 or 3. The arguments zebra and zebra.color are used to make a Zebra striping table(table with alternating background colors) easily. A value of 1 sets background color of all odd rows/columns with specified with zebra.color. A value of 2 sets all even rows/columns. A value of 0 sets background colors of all rows/columns with colors specified with zebra.color. When zebra is 1 or 2, the parameters of prefix.rows and commands ignored. When zebra=3, the background colors can be defined by addRowColor, addColColor and addCellColor functions. Default is NULL.
`zebra.color` | A color name or a numeric value indicating pre-defined color. When parameter zebra is 0 or 1 or 2 and zebra.color is NULL, then zebra.color is set to "platinum". Numeric values between 1 to 13 is converted to predefined color names. The predefined color names are c("peach","peach-orange", "peachpuff","peach-yellow","pear","pearl","peridot","periwinkle","pastelred", "pastelgray"). Default is NULL.
`zebra.type` | An integer of 0 or 1 or 2 or 3. A value of 1 sets background colors by row. A value of 2 sets background colors by column. A value of 0 sets background colors of all cells. A value of 3 sets background colors of cells specified with zebra.list. Default value is 1.
`zebra.colnames` | whether or not use background colors in column names row, Default value is FALSE
`zebra.rownames` | whether or not use background colors in row names column, Default value is TRUE
`zebra.list` | A list consists of y,x,color. zebra.list is used only when zebra.type=3. zebra.list sets the cells specified with rows of vector "y" and columns of vector "x" with "color". The y and x are integer vector indicating rows and columns. NA value of y or x indicating all columns or rows. The color is an character vector consists of names of color.
`colnames.bold` | whether or not use bold font for column names, Default value is FALSE
`include.colnames` | Logical. If TRUE the column names is printed. Default value is TRUE.
`cgroup` | A character vector or matrix indicating names of column group. Default value is NULL
`n.cgroup` | A integer vector or matrix indicating the numbers of columns included in each cgroup Default value is NULL
`rgroup` | A character vector indicating names of row group. Default value is NULL
`n.rgroup` | A integer vector indicating the numbers of rows included in each rgroup Default value is NULL
`cspan.rgroup` | The number of columns that an rgroup should span. It spans by default all columns but you may want to limit this if you have column colors that you want to retain.
`pcol` | number of column displaying p value

### Examples

    require(ztable)
    x=head(iris)
    ztable(x)
    ztable(x,size=3,caption="Table 1. ztable Test")
    ztable(x,size=7,caption="Table 1. ztable Test",caption.position="l")
    ztable(x,size=7,caption="Table 1. ztable Test",caption.placement="bottom",
          caption.position="l")
    fit=lm(mpg~.,data=mtcars)
    ztable(fit)
    data(USArrests)
    pr1 <- prcomp(USArrests)
    ztable(pr1)
    ztable(summary(pr1))
    require(survival)
    data(colon)
    attach(colon)
    out <- glm(status ~ rx+obstruct+adhere+nodes+extent, data=colon, family=binomial)
    ztable(out)
    colon$TS = Surv(time,status==1)
    out1=coxph(TS~rx+obstruct+adhere+differ+extent+surg+node4,data=colon)
    ztable(out1)
    ztable(head(mtcars),zebra=1)
    ztable(head(mtcars),zebra=1,zebra.type=2)

[Package ztable version 0.2.0 Index]