latex.array | R Documentation |
"array"
or "table"
with 3, 4, or more dimensions.
Generate the latex code for an "array"
or "table"
with 3, 4, or more dimensions.
## S3 method for class 'array'
latex(object, ...,
var.sep = "}\\tabularnewline{\\bfseries ", value.sep = ": ",
use.ndn = TRUE, cgroup = NULL,
## rgroup here captures and ignores any incoming rgroup argument
rgroup = NULL, n.rgroup = NULL,
title = first.word(deparse(substitute(object))),
rowlabel=title,
rsubgroup=NULL, n.rsubgroup=NULL)
## S3 method for class 'matrix'
latex(object, ...,
use.ndn=TRUE, cgroup=NULL,
title=first.word(deparse(substitute(object))),
rowlabel=title)
## S3 method for class 'table'
latex(object, ...) ## prepend c("matrix", "array") to the
## class of the input object, and then call latex.default
object |
A |
... |
Arguments forwarded to the "default" method for |
use.ndn |
Logical.
|
rgroup , n.rgroup |
These are the standard arguments for |
rsubgroup , n.rsubgroup |
These are based on the standard arguments for |
title , rowlabel , cgroup |
These are the standard arguments for |
value.sep |
When |
var.sep |
When |
latex.matrix
calls latex.default
directly.
When use.ndn
is TRUE
(the default), rowlabel
and
cgroup
are constructed from names(dimnames(object))
unless the user explicitly specified them.
latex.array
appends all two-dimensional layers
object[,, one, at, a, time]
into a single long "matrix"
,
ignores any incoming rgroup
and n.rgroup
(with a warning),
and constructs rgroup
and n.rgroup
to label the layers.
When use.ndn
is TRUE
(the default), rowlabel
and
cgroup
are constructed from names(dimnames(object))
unless the user explicitly specified them.
latex.table
prepends c("matrix", "array")
to the class of
the "table"
object, then calls the generic "latex"
.
This step is necessary because the survey
package creates
objects whose class includes the value "table"
but not the values
c("matrix", "array")
. Should this object be sent directly to
latex.default
, it would cause on error for any table with
dimension larger than two.
See latex
.
Richard M. Heiberger <rmh@temple.edu>
latex
## Not run:
## These are the recommended options. See ?Hmisc::latex for details.
options(latexcmd='pdflatex')
options(dviExtension='pdf')
options(xdvicmd='open') ## Macintosh, Windows, SMP linux
## End(Not run)
## This sets up the defaults for latex to write to a pdf file
microplot::latexSetOptions()
## It is needed for R CMD check.
## It is recommended if you normally use pdflatex.
## If you want some other destination for latex, use a non-default argument.
tmp3 <- array(1:8, c(2,2,2),
list(letters[1:2],
letters[3:4],
letters[5:6]))
tmp3
ltmp3 <- latex(tmp3) ## assignment prevents display of the generated pdf file
## enter the object name to display the file on screen
## ltmp3
## latex(tmp3) causes a file tmp3.tex to be created in the working directory.
## A user might want to keep tmp3.tex and \input{tmp3.tex} it into a longer .tex file.
## R CMD check doesn't like tmp3.tex to remain, so it is removed here.
file.remove("tmp3.tex")
## Not run:
try( ## warning: Input rgroup and n.rgroup are ignored
latex(tmp3, rgroup=letters[1:3], n.rgroup=c(1,1,2), file="ignorergroup.tex")
)
names(dimnames(tmp3)) <- LETTERS[24:26]
latex(tmp3, file="LETTERS3.tex")
latex(tmp3, rowlabel="Something Else", file="SomethingElse.tex")
tmp4 <- array(1:120, c(5,4,3,2),
list(letters[1:5],
letters[6:9],
letters[10:12],
letters[13:14]))
tmp4
latex(tmp4, var.sep=" ; ")
names(dimnames(tmp4)) <- LETTERS[23:26]
latex(tmp4, file="LETTERS4.tex")
## with rsubgroup and n.rsubgroup
latex(tmp4, var.sep=" ; ", file="LETTERS4sub.tex",
rsubgroup=c("Three","Two"), n.rsubgroup=c(3,2))
## with rsubgroup and n.rsubgroup and cgroup and n.cgroup
latex(tmp4, var.sep=" ; ", file="LETTERS4sub.tex",
rsubgroup=c("Three","Two"), n.rsubgroup=c(3,2),
cgroup=c("FGH","I"), n.cgroup=c(3,1))
tmp2 <- array(1:6, c(3,2),
list(Rows=letters[1:3],
Columns=letters[4:5]))
tmp2
latex(tmp2)
## Input rgroup honored for "matrix"
latex(tmp2, rgroup=c("Two","One"), n.rgroup=c(2,1), file="rgroup.tex")
latex(tmp2, rowlabel="something else", file="something.tex")
## tableDemo is based on a table constructed from
## survey::svytable(~ FactorA + FactorB + FactorC, Survey.Design.Object)
tableDemo <- structure(c(28, 25, 33, 12, 6, 22, 8, 12, 23, 24, 6, 32,
32, 31, 59, 11, 2, 33, 10, 3, 23, 7, 2, 26),
.Dim = c(3L, 4L, 2L),
.Dimnames = list(FactorA = c("a", "b", "c"),
FactorB = c("d", "e", "f", "g"),
FactorC = c("h", "i")),
class = "table")
class(tableDemo)
latex(tableDemo)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.