Format a Data Frame or Matrix for LaTeX or HTML
format.df
does appropriate rounding and decimal alignment, and outputs
a character matrix containing the formatted data. If x
is a
data.frame
, then do each component separately.
If x
is a matrix, but not a data.frame, make it a data.frame
with individual components for the columns.
If a component x$x
is a matrix, then do all columns the same.
format.df(x, digits, dec=NULL, rdec=NULL, cdec=NULL, numeric.dollar=!dcolumn, na.blank=FALSE, na.dot=FALSE, blank.dot=FALSE, col.just=NULL, cdot=FALSE, dcolumn=FALSE, matrix.sep=' ', scientific=c(-4,4), math.row.names=FALSE, already.math.row.names=FALSE, math.col.names=FALSE, already.math.col.names=FALSE, double.slash=FALSE, format.Date="%m/%d/%Y", format.POSIXt="%m/%d/%Y %H:%M:%OS", ...)
x |
a matrix (usually numeric) or data frame |
digits |
causes all values in the table to be formatted to |
dec |
If |
rdec |
a vector specifying the number of decimal places to the right for each row
( |
cdec |
a vector specifying the number of decimal places for each column. The vector must have number of items equal to number of columns or components of input x. |
cdot |
Set to |
na.blank |
Set to |
dcolumn |
Set to |
numeric.dollar |
logical, default |
math.row.names |
logical, set true to place dollar signs around the row names. |
already.math.row.names |
set to |
math.col.names |
logical, set true to place dollar signs around the column names. |
already.math.col.names |
set to |
na.dot |
Set to |
blank.dot |
Set to |
col.just |
Input vector |
matrix.sep |
When |
scientific |
specifies ranges of exponents (or a logical vector) specifying values
not to convert to scientific notation. See |
double.slash |
should escaping backslashes be themselves escaped. |
format.Date |
String used to format objects of the Date class. |
format.POSIXt |
String used to format objects of the POSIXt class. |
... |
other arguments are accepted and passed to |
a character matrix with character images of properly rounded x
.
Matrix components of input x
are now just sets of columns of
character matrix.
Object attribute"col.just"
repeats the value of the argument col.just
when provided,
otherwise, it includes the recommended justification for columns of output.
See the discussion of the argument col.just
.
The default justification is l for characters and factors,
r for numeric.
When dcolumn==TRUE
, numerics will have . as the justification character.
Frank E. Harrell, Jr.,
Department of Biostatistics,
Vanderbilt University,
fh@fharrell.com
Richard M. Heiberger,
Department of Statistics,
Temple University, Philadelphia, PA.
rmh@astro.ocis.temple.edu
## Not run: x <- data.frame(a=1:2, b=3:4) x$m <- 10000*matrix(5:8,nrow=2) names(x) dim(x) x format.df(x, big.mark=",") dim(format.df(x)) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.