Skip to contents

Apply alignments to a flextable

Usage

apply_alignments(flx, aligns_df, part)

Arguments

flx

(flextable)
a flextable object to which alignments will be applied.

aligns_df

(matrix)
a matrix object containing the alignments that will be applied.

part

(character)
the part of flx where the alignments will be applied. One of: "header", "body" or "footer".

Value

a flextable object with the alignments updated.

Examples

df <- head(iris)
aligns_df <- matrix(data = "right", nrow = nrow(df), ncol = ncol(df))
aligns_df[3, 3] <- "center"
aligns_df[5, 2] <- "center"
flx <- flextable::flextable(df)
apply_alignments(flx = flx, aligns_df = aligns_df, part = "body")

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

Species

5.1

3.5

1.4

0.2

setosa

4.9

3.0

1.4

0.2

setosa

4.7

3.2

1.3

0.2

setosa

4.6

3.1

1.5

0.2

setosa

5.0

3.6

1.4

0.2

setosa

5.4

3.9

1.7

0.4

setosa