print.xtableMatharray: Print Math Array

Description Usage Arguments Details Value Author(s) See Also Examples

Description

For an object of class "xtableMatharray", returns the LaTeX commands to produce an array.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'xtableMatharray'
print(x,
  print.results = TRUE,
  format.args = getOption("xtable.format.args", NULL),
  scalebox = getOption("xtable.scalebox", NULL),
  comment = FALSE,
  timestamp = NULL,
  ...)

Arguments

x

An object of class "xtableMatharray".

print.results

If TRUE, the generated table is printed to standard output. Set this to FALSE if you will just be using the character vector that is returned invisibly. Default value is TRUE.

format.args

List of arguments for the formatC function. For example, standard German number separators can be specified as format.args=list(big.mark = "'", decimal.mark = ","). The arguments digits and format should not be included in this list. See details for function print.xtable. Default value is NULL.

scalebox

If not NULL, a scalebox clause will be added around the tabular environment with the specified value used as the scaling factor. Default value is NULL.

comment

If TRUE, the version and timestamp comment is included. Default value is FALSE.

timestamp

Timestamp to include in LaTeX comment. Set this to NULL to exclude the timestamp. Default value is NULL.

...

Additional arguments. (Currently ignored.)

Details

This command prints an array of numbers which may be included in a mathematical expression in a LaTeX document created using Sweave or knitr. Internally it calls print.data.frame but with special values for the arguments, namely that the tabular environment is array, row names and column names are not included, and there are no horizontal lines. Note that the default values for the arguments comment and timestamp are different to the default values for print.xtable, the justification being that comments would make the resulting LaTeX harder to read.

Value

A character vector containing the LaTeX code for incorporating an array in a mathematical expression.

Author(s)

David Scott d.scott@auckland.ac.nz.

See Also

xtableMatharray, print.xtable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
V <- matrix(c(1.140380e-03,  3.010497e-05,  7.334879e-05,
              3.010497e-05,  3.320683e-04, -5.284854e-05,
              7.334879e-05, -5.284854e-05,  3.520928e-04), nrow = 3)
### Simple test of print.xtableMatharray
print.xtableMatharray(xtable(V, display = rep("E", 4)))

class(V) <- c("xtableMatharray")
class(V)

### Test without any additional arguments
mth <- xtableMatharray(V)
str(mth)
print(mth)

### Test with arguments to xtable
mth <- xtableMatharray(V, display = rep("E", 4))
str(mth)
print(mth)

mth <- xtableMatharray(V, digits = 6)
str(mth)
print(mth)

### Test with additional print.xtableMatharray arguments
mth <- xtableMatharray(V, digits = 6)
str(mth)
print(mth, format.args = list(decimal.mark = ","))
print(mth, scalebox = 0.5)
print(mth, comment = TRUE)
print(mth, timestamp = "2000-01-01")
print(mth, comment = TRUE, timestamp = "2000-01-01")

Example output

\begin{array}{rrr}
  1.14E-03 & 3.01E-05 & 7.33E-05 \\ 
  3.01E-05 & 3.32E-04 & -5.28E-05 \\ 
  7.33E-05 & -5.28E-05 & 3.52E-04 \\ 
  \end{array}
[1] "xtableMatharray"
Classes 'xtableMatharray', 'xtable' and 'data.frame':	3 obs. of  3 variables:
 $ 1: num  1.14e-03 3.01e-05 7.33e-05
 $ 2: num  3.01e-05 3.32e-04 -5.28e-05
 $ 3: num  7.33e-05 -5.28e-05 3.52e-04
 - attr(*, "align")= chr  "r" "r" "r" "r"
 - attr(*, "digits")= num  0 2 2 2
 - attr(*, "display")= chr  "s" "f" "f" "f"
\begin{array}{rrr}
  0.00 & 0.00 & 0.00 \\ 
  0.00 & 0.00 & -0.00 \\ 
  0.00 & -0.00 & 0.00 \\ 
  \end{array}
Classes 'xtableMatharray', 'xtable' and 'data.frame':	3 obs. of  3 variables:
 $ 1: num  1.14e-03 3.01e-05 7.33e-05
 $ 2: num  3.01e-05 3.32e-04 -5.28e-05
 $ 3: num  7.33e-05 -5.28e-05 3.52e-04
 - attr(*, "align")= chr  "r" "r" "r" "r"
 - attr(*, "digits")= num  0 2 2 2
 - attr(*, "display")= chr  "E" "E" "E" "E"
\begin{array}{rrr}
  1.14E-03 & 3.01E-05 & 7.33E-05 \\ 
  3.01E-05 & 3.32E-04 & -5.28E-05 \\ 
  7.33E-05 & -5.28E-05 & 3.52E-04 \\ 
  \end{array}
Classes 'xtableMatharray', 'xtable' and 'data.frame':	3 obs. of  3 variables:
 $ 1: num  1.14e-03 3.01e-05 7.33e-05
 $ 2: num  3.01e-05 3.32e-04 -5.28e-05
 $ 3: num  7.33e-05 -5.28e-05 3.52e-04
 - attr(*, "align")= chr  "r" "r" "r" "r"
 - attr(*, "digits")= num  6 6 6 6
 - attr(*, "display")= chr  "s" "f" "f" "f"
\begin{array}{rrr}
  0.001140 & 0.000030 & 0.000073 \\ 
  0.000030 & 0.000332 & -0.000053 \\ 
  0.000073 & -0.000053 & 0.000352 \\ 
  \end{array}
Classes 'xtableMatharray', 'xtable' and 'data.frame':	3 obs. of  3 variables:
 $ 1: num  1.14e-03 3.01e-05 7.33e-05
 $ 2: num  3.01e-05 3.32e-04 -5.28e-05
 $ 3: num  7.33e-05 -5.28e-05 3.52e-04
 - attr(*, "align")= chr  "r" "r" "r" "r"
 - attr(*, "digits")= num  6 6 6 6
 - attr(*, "display")= chr  "s" "f" "f" "f"
\begin{array}{rrr}
  0,001140 & 0,000030 & 0,000073 \\ 
  0,000030 & 0,000332 & -0,000053 \\ 
  0,000073 & -0,000053 & 0,000352 \\ 
  \end{array}
\scalebox{0.5}{
\begin{array}{rrr}
  0.001140 & 0.000030 & 0.000073 \\ 
  0.000030 & 0.000332 & -0.000053 \\ 
  0.000073 & -0.000053 & 0.000352 \\ 
  \end{array}
}
% latex table generated in R 3.4.4 by xtable 1.8-4 package
\begin{array}{rrr}
  0.001140 & 0.000030 & 0.000073 \\ 
  0.000030 & 0.000332 & -0.000053 \\ 
  0.000073 & -0.000053 & 0.000352 \\ 
  \end{array}
\begin{array}{rrr}
  0.001140 & 0.000030 & 0.000073 \\ 
  0.000030 & 0.000332 & -0.000053 \\ 
  0.000073 & -0.000053 & 0.000352 \\ 
  \end{array}
% latex table generated in R 3.4.4 by xtable 1.8-4 package
% 2000-01-01
\begin{array}{rrr}
  0.001140 & 0.000030 & 0.000073 \\ 
  0.000030 & 0.000332 & -0.000053 \\ 
  0.000073 & -0.000053 & 0.000352 \\ 
  \end{array}

xtable documentation built on May 2, 2019, 2:15 p.m.