
Last chance! 50% off unlimited learning
Sale ends in
Get a flextable
object from
a xtable
object.
# S3 method for xtable
as_flextable(
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),
...
)
xtable
object
default text formatting properties
List of arguments for the formatC function.
See argument format.args
of print.xtable
. Not yet
implemented.
colname used for row names column
see ?print.xtable
.
see ?print.xtable
.
see ?print.xtable
.
see ?print.xtable
.
unused arguments
Other as_flextable methods:
as_flextable.gam()
,
as_flextable.glm()
,
as_flextable.grouped_data()
,
as_flextable.htest()
,
as_flextable.lm()
,
as_flextable.summarizor()
,
as_flextable.tabulator()
,
as_flextable()
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)
}
Run the code above in your browser using DataLab