-
Notifications
You must be signed in to change notification settings - Fork 79
/
as_flextable.xtable.Rd
101 lines (90 loc) · 2.88 KB
/
as_flextable.xtable.Rd
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xtable_to_flextable.R
\name{as_flextable.xtable}
\alias{as_flextable.xtable}
\title{Transform a 'xtable' object into a flextable}
\usage{
\method{as_flextable}{xtable}(
x,
text.properties = fp_text_default(),
format.args = getOption("xtable.format.args", NULL),
rowname_col = "rowname",
hline.after = getOption("xtable.hline.after", c(-1, 0, nrow(x))),
NA.string = getOption("xtable.NA.string", ""),
include.rownames = TRUE,
rotate.colnames = getOption("xtable.rotate.colnames", FALSE),
...
)
}
\arguments{
\item{x}{\code{xtable} object}
\item{text.properties}{default text formatting properties}
\item{format.args}{List of arguments for the formatC function.
See argument \code{format.args} of \code{print.xtable}. Not yet
implemented.}
\item{rowname_col}{colname used for row names column}
\item{hline.after}{see \code{?print.xtable}.}
\item{NA.string}{see \code{?print.xtable}.}
\item{include.rownames}{see \code{?print.xtable}.}
\item{rotate.colnames}{see \code{?print.xtable}.}
\item{...}{unused arguments}
}
\description{
Get a \code{flextable} object from
a \code{xtable} object.
}
\examples{
library(officer)
if( require("xtable") ){
data(tli)
tli.table <- xtable(tli[1:10, ])
align(tli.table) <- rep("r", 6)
align(tli.table) <- "|r|r|clr|r|"
ft_1 <- as_flextable(
tli.table,
rotate.colnames = TRUE,
include.rownames = FALSE)
ft_1 <- height(ft_1, i = 1, part = "header", height = 1)
ft_1
\donttest{
Grade3 <- c("A","B","B","A","B","C","C","D","A","B",
"C","C","C","D","B","B","D","C","C","D")
Grade6 <- c("A","A","A","B","B","B","B","B","C","C",
"A","C","C","C","D","D","D","D","D","D")
Cohort <- table(Grade3, Grade6)
ft_2 <- as_flextable(xtable(Cohort))
ft_2 <- set_header_labels(ft_2, rowname = "Grade 3")
ft_2 <- autofit(ft_2)
ft_2 <- add_header(ft_2, A = "Grade 6")
ft_2 <- merge_at(ft_2, i = 1, j = seq_len( ncol(Cohort) ) + 1,
part = "header" )
ft_2 <- bold(ft_2, j = 1, bold = TRUE, part = "body")
ft_2 <- height_all(ft_2, part = "header", height = .4)
ft_2
temp.ts <- ts(cumsum(1 + round(rnorm(100), 0)),
start = c(1954, 7), frequency = 12)
ft_3 <- as_flextable(x = xtable(temp.ts, digits = 0),
NA.string = "-")
ft_3
}
detach("package:xtable", unload = TRUE)
}
}
\seealso{
Other as_flextable methods:
\code{\link{as_flextable}()},
\code{\link{as_flextable.data.frame}()},
\code{\link{as_flextable.gam}()},
\code{\link{as_flextable.glm}()},
\code{\link{as_flextable.grouped_data}()},
\code{\link{as_flextable.htest}()},
\code{\link{as_flextable.kmeans}()},
\code{\link{as_flextable.lm}()},
\code{\link{as_flextable.merMod}()},
\code{\link{as_flextable.pam}()},
\code{\link{as_flextable.summarizor}()},
\code{\link{as_flextable.table}()},
\code{\link{as_flextable.tabular}()},
\code{\link{as_flextable.tabulator}()}
}
\concept{as_flextable methods}