-
Notifications
You must be signed in to change notification settings - Fork 79
/
add_body.Rd
70 lines (63 loc) · 2.14 KB
/
add_body.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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/augment_rows.R
\name{add_body}
\alias{add_body}
\title{Add column values as new lines in body}
\usage{
add_body(x, top = TRUE, ..., values = NULL)
}
\arguments{
\item{x}{a flextable object}
\item{top}{should the rows be inserted at the top or the bottom.}
\item{...}{named arguments (names are data colnames) of values
to add. It is important to insert data of the same type as the
original data, otherwise it will be transformed (probably
into strings if you add a \code{character} where a \code{double} is expected).
This makes possible to still format cell contents with the \verb{colformat_*}
functions, for example \code{\link[=colformat_num]{colformat_num()}}.}
\item{values}{a list of name-value pairs of labels or values,
names should be existing col_key values. This argument can be used
instead of \code{...} for programming purpose (If \code{values} is
supplied argument \code{...} is ignored).}
}
\description{
The function adds a list of values to be inserted as
new rows in the body. The values are inserted in
existing columns of the input data of the flextable.
Rows can be inserted at the top or the bottom of
the body.
If some columns are not provided, they will be replaced by
\code{NA} and displayed as empty.
}
\examples{
ft <- flextable(head(iris),
col_keys = c(
"Species", "Sepal.Length", "Petal.Length",
"Sepal.Width", "Petal.Width"
)
)
ft <- add_body(
x = ft, Sepal.Length = 1:5,
Sepal.Width = 1:5 * 2, Petal.Length = 1:5 * 3,
Petal.Width = 1:5 + 10, Species = "Blah", top = FALSE
)
ft <- theme_booktabs(ft)
ft
}
\seealso{
\code{\link[=flextable]{flextable()}}
Other functions for row and column operations in a flextable:
\code{\link{add_body_row}()},
\code{\link{add_footer}()},
\code{\link{add_footer_lines}()},
\code{\link{add_footer_row}()},
\code{\link{add_header}()},
\code{\link{add_header_row}()},
\code{\link{delete_columns}()},
\code{\link{delete_part}()},
\code{\link{delete_rows}()},
\code{\link{separate_header}()},
\code{\link{set_header_footer_df}},
\code{\link{set_header_labels}()}
}
\concept{functions for row and column operations in a flextable}