mylatex: Exporting "cbind.mytable","mytable" to LaTeX format

Description Usage Arguments Methods (by class) Examples

View source: R/mylatex.R

Description

Exporting "cbind.mytable","mytable" to LaTeX format

Usage

 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
mylatex(
  myobj,
  size = 5,
  caption = NULL,
  caption.placement = "top",
  caption.position = "c"
)

## Default S3 method:
mylatex(
  myobj,
  size = 5,
  caption = NULL,
  caption.placement = "top",
  caption.position = "c"
)

## S3 method for class 'mytable'
mylatex(
  myobj,
  size = 5,
  caption = NULL,
  caption.placement = "top",
  caption.position = "c"
)

## S3 method for class 'cbind.mytable'
mylatex(
  myobj,
  size = 5,
  caption = NULL,
  caption.placement = "top",
  caption.position = "c"
)

Arguments

myobj

An object of class 'mytable'

size

An integer indicating font size, defaulting is 5.

caption

A character

caption.placement

The caption will be have placed at the top of the table if caption.placement is "top" and at the bottom of the table if it equals "bottom". Default value is "top".

caption.position

The caption will be have placed at the center of the table if caption.position is "center" or "c", and at the left side of the table if it equals "left" or "l", and at the right side of the table if it equals "right" or "r". Default value is "center".

Methods (by class)

Examples

1
2
3
4
5
require(moonBook)
out=mytable(sex~.,data=acs)
mylatex(out)
out1=mytable(sex+Dx~.,data=acs)
mylatex(out1,size=6)

Example output

\begin{table}[!hbp]
\begin{normalsize}
\begin{tabular}{lccc}
\multicolumn{4}{c}{Descriptive Statistics by sex}\\ 
\hline
 & Female & Male & \multirow{2}{*}{p}\\ 
 & (N=287) & (N=570) &  \\ 
\hline
age                 & 68.7 <U+00B1> 10.7 & 60.6 <U+00B1> 11.2 & 0.000\\ 
cardiogenicShock    &  &  & 0.136\\ 
  - No              & 275 (95.8\%) & 530 (93.0\%) & \\ 
  - Yes             & 12 ( 4.2\%) & 40 ( 7.0\%) & \\ 
entry               &  &  & 0.035\\ 
  - Femoral         & 119 (41.5\%) & 193 (33.9\%) & \\ 
  - Radial          & 168 (58.5\%) & 377 (66.1\%) & \\ 
Dx                  &  &  & 0.012\\ 
  - NSTEMI          & 50 (17.4\%) & 103 (18.1\%) & \\ 
  - STEMI           & 84 (29.3\%) & 220 (38.6\%) & \\ 
  - Unstable Angina & 153 (53.3\%) & 247 (43.3\%) & \\ 
EF                  & 56.3 <U+00B1> 10.1 & 55.6 <U+00B1>  9.4 & 0.387\\ 
height              & 153.8 <U+00B1>  6.2 & 167.9 <U+00B1>  6.1 & 0.000\\ 
weight              & 57.2 <U+00B1>  9.3 & 68.7 <U+00B1> 10.3 & 0.000\\ 
BMI                 & 24.2 <U+00B1>  3.6 & 24.3 <U+00B1>  3.2 & 0.611\\ 
obesity             &  &  & 0.580\\ 
  - No              & 194 (67.6\%) & 373 (65.4\%) & \\ 
  - Yes             & 93 (32.4\%) & 197 (34.6\%) & \\ 
TC                  & 188.9 <U+00B1> 51.1 & 183.3 <U+00B1> 45.9 & 0.124\\ 
LDLC                & 117.8 <U+00B1> 41.2 & 116.0 <U+00B1> 41.1 & 0.561\\ 
HDLC                & 39.0 <U+00B1> 11.5 & 37.8 <U+00B1> 10.9 & 0.145\\ 
TG                  & 119.9 <U+00B1> 76.2 & 127.9 <U+00B1> 97.3 & 0.195\\ 
DM                  &  &  & 0.077\\ 
  - No              & 173 (60.3\%) & 380 (66.7\%) & \\ 
  - Yes             & 114 (39.7\%) & 190 (33.3\%) & \\ 
HBP                 &  &  & 0.000\\ 
  - No              & 83 (28.9\%) & 273 (47.9\%) & \\ 
  - Yes             & 204 (71.1\%) & 297 (52.1\%) & \\ 
smoking             &  &  & 0.000\\ 
  - Ex-smoker       & 49 (17.1\%) & 155 (27.2\%) & \\ 
  - Never           & 209 (72.8\%) & 123 (21.6\%) & \\ 
  - Smoker          & 29 (10.1\%) & 292 (51.2\%) & \\ 
\hline
\end{tabular}
\end{normalsize}
\end{table}
\begin{table}[!hbp]
\begin{large}
\centering
\begin{tabular}{lccccccccc}
\multicolumn{10}{c}{Descriptive Statistics stratified by sex and Dx}\\ 
\hline
 & \multicolumn{4}{c}{Male}  &  &\multicolumn{4}{c}{Female} \\ 
\cline{2-5}\cline{7-10} 
  & NSTEMI & STEMI & Unstable Angina & p &  & NSTEMI & STEMI & Unstable Angina & p \\ 
  & (N=103) & (N=220) & (N=247) &  &  & (N=50) & (N=84) & (N=153) &  \\ 
\hline
age              & 61.1 <U+00B1> 11.6 & 59.4 <U+00B1> 11.7 & 61.4 <U+00B1> 10.6 & 0.133 &  & 70.9 <U+00B1> 11.4 & 69.1 <U+00B1> 10.4 & 67.7 <U+00B1> 10.7 & 0.177 \\ 
cardiogenicShock &  &  &  & 0.000 &  &  &  &  & 0.000 \\ 
  - No           & 100 (97.1\%) & 183 (83.2\%) & 247 (100.0\%) &  &  & 49 (98.0\%) & 73 (86.9\%) & 153 (100.0\%) &  \\ 
  - Yes          & 3 ( 2.9\%) & 37 (16.8\%) & 0 ( 0.0\%) &  &  & 1 ( 2.0\%) & 11 (13.1\%) & 0 ( 0.0\%) &  \\ 
entry            &  &  &  & 0.022 &  &  &  &  & 0.013 \\ 
  - Femoral      & 36 (35.0\%) & 88 (40.0\%) & 69 (27.9\%) &  &  & 22 (44.0\%) & 45 (53.6\%) & 52 (34.0\%) &  \\ 
  - Radial       & 67 (65.0\%) & 132 (60.0\%) & 178 (72.1\%) &  &  & 28 (56.0\%) & 39 (46.4\%) & 101 (66.0\%) &  \\ 
EF               & 55.1 <U+00B1>  9.4 & 52.4 <U+00B1>  8.9 & 59.1 <U+00B1>  8.7 & 0.000 &  & 54.8 <U+00B1>  9.1 & 52.3 <U+00B1> 10.9 & 59.4 <U+00B1>  8.8 & 0.000 \\ 
height           & 167.5 <U+00B1>  5.7 & 168.7 <U+00B1>  6.0 & 167.3 <U+00B1>  6.4 & 0.055 &  & 154.2 <U+00B1>  5.1 & 155.7 <U+00B1>  5.4 & 152.6 <U+00B1>  6.7 & 0.002 \\ 
weight           & 67.5 <U+00B1>  8.4 & 68.8 <U+00B1> 10.9 & 69.0 <U+00B1> 10.6 & 0.479 &  & 57.2 <U+00B1> 10.3 & 57.4 <U+00B1>  9.0 & 57.1 <U+00B1>  9.1 & 0.978 \\ 
BMI              & 24.1 <U+00B1>  2.6 & 24.1 <U+00B1>  3.4 & 24.6 <U+00B1>  3.4 & 0.205 &  & 24.1 <U+00B1>  4.3 & 23.6 <U+00B1>  3.2 & 24.5 <U+00B1>  3.5 & 0.215 \\ 
obesity          &  &  &  & 0.301 &  &  &  &  & 0.528 \\ 
  - No           & 71 (68.9\%) & 149 (67.7\%) & 153 (61.9\%) &  &  & 35 (70.0\%) & 60 (71.4\%) & 99 (64.7\%) &  \\ 
  - Yes          & 32 (31.1\%) & 71 (32.3\%) & 94 (38.1\%) &  &  & 15 (30.0\%) & 24 (28.6\%) & 54 (35.3\%) &  \\ 
TC               & 192.6 <U+00B1> 54.3 & 184.1 <U+00B1> 42.6 & 178.7 <U+00B1> 44.6 & 0.036 &  & 196.3 <U+00B1> 52.7 & 180.7 <U+00B1> 45.7 & 191.1 <U+00B1> 53.1 & 0.192 \\ 
LDLC             & 125.4 <U+00B1> 47.1 & 118.9 <U+00B1> 39.1 & 109.5 <U+00B1> 39.2 & 0.002 &  & 127.7 <U+00B1> 39.5 & 111.0 <U+00B1> 40.0 & 118.3 <U+00B1> 41.8 & 0.088 \\ 
HDLC             & 38.4 <U+00B1> 10.9 & 38.1 <U+00B1> 10.9 & 37.4 <U+00B1> 10.9 & 0.655 &  & 40.1 <U+00B1> 13.8 & 39.5 <U+00B1> 11.2 & 38.5 <U+00B1> 10.8 & 0.627 \\ 
TG               & 138.0 <U+00B1> 100.2 & 104.3 <U+00B1> 65.5 & 144.3 <U+00B1> 114.2 & 0.000 &  & 112.5 <U+00B1> 51.1 & 112.3 <U+00B1> 87.2 & 126.3 <U+00B1> 76.0 & 0.316 \\ 
DM               &  &  &  & 0.219 &  &  &  &  & 0.240 \\ 
  - No           & 71 (68.9\%) & 154 (70.0\%) & 155 (62.8\%) &  &  & 25 (50.0\%) & 54 (64.3\%) & 94 (61.4\%) &  \\ 
  - Yes          & 32 (31.1\%) & 66 (30.0\%) & 92 (37.2\%) &  &  & 25 (50.0\%) & 30 (35.7\%) & 59 (38.6\%) &  \\ 
HBP              &  &  &  & 0.016 &  &  &  &  & 0.084 \\ 
  - No           & 43 (41.7\%) & 122 (55.5\%) & 108 (43.7\%) &  &  & 19 (38.0\%) & 28 (33.3\%) & 36 (23.5\%) &  \\ 
  - Yes          & 60 (58.3\%) & 98 (44.5\%) & 139 (56.3\%) &  &  & 31 (62.0\%) & 56 (66.7\%) & 117 (76.5\%) &  \\ 
smoking          &  &  &  & 0.002 &  &  &  &  & 0.184 \\ 
  - Ex-smoker    & 34 (33.0\%) & 53 (24.1\%) & 68 (27.5\%) &  &  & 8 (16.0\%) & 13 (15.5\%) & 28 (18.3\%) &  \\ 
  - Never        & 13 (12.6\%) & 40 (18.2\%) & 70 (28.3\%) &  &  & 37 (74.0\%) & 57 (67.9\%) & 115 (75.2\%) &  \\ 
  - Smoker       & 56 (54.4\%) & 127 (57.7\%) & 109 (44.1\%) &  &  & 5 (10.0\%) & 14 (16.7\%) & 10 ( 6.5\%) &  \\ 
\hline
\end{tabular}
\end{large}
\end{table}

moonBook documentation built on Jan. 5, 2022, 9:06 a.m.