pxtable: print data.frame in LaTeX

View source: R/pxtable.R

pxtableR Documentation

print data.frame in LaTeX

Description

This function adds to the print function of the xtable package by providing predefined add.to.row code for the longtable LaTeX package: 'continued on/from ...' and 'end of table' lines that can switched on or off. This functionality can only be used with the longtable environment. When scalebox is specified the tabular environment is used and add.to.row code is not available. If the longtable package is not available then set scalebox=1 or another appropriate value.

Usage

pxtable(
  df,
  tablabel = "",
  tabcap = "",
  adef = "l",
  ap = c(),
  av = c(),
  ddef = 0,
  dp = c(),
  dv = c(),
  tco = T,
  tcf = tco,
  te = F,
  newpage = F,
  scalebox = NULL,
  include.colnames = T,
  colnames = NA,
  rotate.colnames = T,
  include.rownames = F,
  sanitize.colnames.function = xtable::sanitize,
  booktabs = F,
  ...
)

Arguments

df

data.frame that will be printed.

tablabel

Character string that can be used to reference the table as table:tablabel. Default: ”

tabcap

Character string that is as caption for the table. Default: ”

adef

Character string with the default alignment. Default: "l"

ap

Integer vector with the positions of the columns for which an alignment specification is given in av. Default: c()

av

Character vector with aligment specifications for the positions in ap. E.g. with values as 'c', 'r', 'p3cm' . Default: c()

ddef

Integer with the default number of digits to display. Default: 0

dp

Integer vector with the positions of the columns for which an digit specification is given in dv. Default: c()

dv

Integer vector with digit specifications for the positions in dp. Default: c()

tco

Boolean indicating if 'continued on' should be displayed at the bottom of a page(only) when using the longtable package. Default: T

tcf

Boolean indicating if 'continued from' should be displayed at the top of a page(only) when using the longtable package. Default: tco

te

Boolean indicating if 'end of table' should be displayed at the end of the table (only) when using the longtable package. Default: F

newpage

Boolean indicating if the table should start on a new page. Default: F

scalebox

Positive number for scaling the table. Forces the tabular environment. See xtable::print.xtable. Default: NULL

include.colnames

Boolean indicating if column names will be printed. See xtable::print.xtable. Default: T

colnames

Character vector with column headers to use instead of field names. Default: NA

rotate.colnames

Boolean indicating if column names will be printed vertically. See xtable::print.xtable. Default: T

include.rownames

Boolean indicating if row names will be printed. See xtable::print.xtable. Default: F

sanitize.colnames.function

Function used for nicer printing of column names. See xtable::print.xtable. Default: xtable::sanitize

booktabs

Boolean indicating if LaTeX package booktabs will be used for formatting horizontal lines. See xtable::print.xtable. Default: F

...

Additional arguments that are passed to xtable::print.xtable.

Value

See xtable::print.xtable as this function prepares only its function arguments. Using this function in a knitr chunk with results ='markup' will show the generated LaTeX text. With results ='asis' the text is transfered to the intermediate output file and interpreted as LaTeX in the final pdf document.

Examples

## Not run: 
df1 = data.frame(
 v1 = rep(c(1,NA),50),
 v2 = rep(c('R version 3.5.0', 'R is free software'),50),
 v3 = rep(c('Copyright (C) 2019', 'You are welcome'),50),
 v4 = rep(c('a','b'),50),
 v5 = rep(c(pi,NA),50),
 stringsAsFactors = F
)

pxtable  (df1,tablabel='tab1',tabcap='mycaption',
	ap = 1:4, av = c("r", "p{6cm}", "p{6cm}", "c"), adef = "l",
	dp = c(1, 5), dv = c(2, 3), ddef = 0, te = F,
	include.rownames = T,
	rotate.rownames = T # example of an argument that will be passed to xtable::print.xtable
)

## End(Not run)

HanOostdijk/HOQCutil documentation built on July 28, 2023, 5:56 p.m.