File: latex.psm.s

package info (click to toggle)
r-cran-rms 5.1-3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,160 kB
  • sloc: asm: 18,851; fortran: 823; ansic: 19; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,450 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
latex.psm <-
  function(object,  title,
           file='',
           append=FALSE, which=NULL, varnames, 
           columns=65, inline=FALSE, 
           before=if(inline)"" else "& &", after="",
           pretrans=TRUE, caption=NULL, digits=.Options$digits, size='',
           ...)
{
  md <- prType() %in% c('html', 'md', 'markdown')
  
  f <- object
  whichNot <- length(which)==0
  
  w <- if(length(caption)) {
         if(md) paste('<div align=center><strong>', caption,
                      '</strong></div>', sep='')
         else
           paste('\\begin{center} \\bf',caption,'\\end{center}')
         }

  if(whichNot & !inline)
    {
      dist <- f$dist
      w <- c(w, paste("\\[{\\rm Prob}\\{T\\geq t\\} = ",
                      survreg.auxinfo[[dist]]$latex(f$scale),
                      "{\\rm \\ \\ where} \\\\ \\]",sep=""))
    }
  atr <- f$Design

  if(whichNot) which <- 1:length(atr$name)
  if(missing(varnames)) varnames <- atr$name[atr$assume.code!=9]

  if(! md)
    cat(w, sep=if(length(w)) "\n" else "", file=file, append=append)
  z <- latexrms(f, file=file, append=TRUE, which=which,
                varnames=varnames, columns=columns, 
                before=before, after=after,
                prefix=if(whichNot)"X\\hat{\\beta}" else NULL, 
                inline=inline,pretrans=pretrans, digits=digits,
                size=size)
  if(md) htmltools::HTML(c(paste0(w, '\n'), as.character(z)))
  else z
}