as_flextable_methods: Method to transform objects into flextables

as_flextable_methodsR Documentation

Method to transform objects into flextables

Description

This is a convenient function to let users create flextable bindings from any objects. Users should consult documentation of corresponding method to understand the details and see what arguments can be used.

Usage

## S3 method for class 'grouped_df'
as_flextable(
  x,
  groups_to = c("titles", "merged", "asis"),
  groups_pos = c("left", "asis"),
  groups_arrange = NULL,
  ...
)

## S3 method for class 'data.frame'
as_flextable(x, col_keys = names(x), ...)

Arguments

x

object to be transformed as flextable

groups_to

One of titles, merged, or asis. See examples and vignette("group-rows") for the result.

groups_pos

When groups_to = "merged", grouping columns are reordered according to group_pos. Choices are left (default) or asis.

groups_arrange

TRUE automatically arranges grouping columns by dplyr::arrange(). Specify FALSE to keep the arrangement of the input data frame. The default value is NULL which implies FALSE to keep the backward compatibility, but will be TRUE in the future.

...

arguments for custom methods

col_keys

columns names/keys to display. If some column names are not in the dataset, they will be added as blank columns by default.

See Also

Other as_flextable methods: as_flextable.data.frame(), as_flextable.gam(), as_flextable.glm(), as_flextable.grouped_data(), as_flextable.htest(), as_flextable.kmeans(), as_flextable.lm(), as_flextable.merMod(), as_flextable.pam(), as_flextable.summarizor(), as_flextable.table(), as_flextable.tabular(), as_flextable.tabulator(), as_flextable.xtable()

Examples


# For grouped_df
grouped_df <- iris %>%
  dplyr::group_by(Species) %>%
  dplyr::slice(1, 2)

as_flextable(grouped_df, groups_to = "titles")
as_flextable(grouped_df, groups_to = "titles", hide_grouplabel = TRUE)
as_flextable(grouped_df, groups_to = "merged")
as_flextable(grouped_df, groups_to = "asis")
# For data.frame
iris %>%
  head() %>%
  as_flextable()

ftExtra documentation built on Sept. 29, 2023, 9:06 a.m.