Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
charvec_to_formula
Description
charvec_to_formula
Usage
charvec_to_formula(chr)
Arguments
chr
character vector
Value
a formula
finish excel workbook
Description
finish excel workbook
Usage
finish_excel_wb(wb, wb_name)
Arguments
wb
wb
wb_name
wb name
Value
an excel file
flex_create_headers
Description
create data frame of header specifications for flextable::set_header_df
Usage
flex_create_headers(df, word_vec)
Arguments
df
a data frame
word_vec
word vec
Value
data frame
flex_mergev1
Description
flex_mergev1
Usage
flex_mergev1(x, df)
Arguments
x
a flextable
df
data frame
Value
a flextable
flex_mergev1_formula
Description
flex_mergev1_formula
Usage
flex_mergev1_formula(df)
Arguments
df
a dataframe
Value
a formula
charvec_to_formula
Description
charvec_to_formula
Usage
flex_set_headers(x, df, word_vec)
Arguments
x
flextable
df
data frame
word_vec
word
Value
a flextable
format number
Description
Number formatters to apply to a column in a dataframe. Helpful for displaying tibbles in console or in conjunction
with make_flextable .
Based off the formattable package.
Usage
format_number(tbl, ..., digits = 0)
format_percent(tbl, ..., digits = 0)
format_currency(tbl, ..., symbol = "yen", digits = 0)
Arguments
tbl
dataframe
...
tidyselect.
digits
integer. trailing digits
symbol
chr. currency symbol
Details
format_numberformats a number accounting style by inserting commas. default selection is integer columnsformat_percentformats a number as a percentage. default selection is numeric columns in between -1 and 1.format_currencyformats a monetary value with the currency symbol. default currency symbol is yen.
Value
dataframe
dataframe
Examples
tibble::tibble(
y = seq(1000L, 10000L, by = 1000L),
z = c(-.59, -.23, -.11, 0, .1, .21, .3, .4, .6, .9),
w = c(.1, 1.4, .23, -.10, 0, -2.3, .2,.3,.4,.5)) -> tbl1
tbl1
# automatically formats the integer column
tbl1 %>%
format_number()
# automatically formats to yen
tbl1 %>%
format_currency(y)
# automatically detects columns between -1 and 1 to convert to percentages
tbl1 %>%
format_percent()
# select specific columns to convert.
tbl1 %>%
format_percent(z, w)
format_red
Description
format_red
Usage
format_red(flextbl, col, clr = "firebrick3")
Arguments
flextbl
flextable
col
string. col name
clr
color
Value
flextable
get piped name
Description
this function captures the name of an object piped into a function, and returns as a string. Powers the automatic naming found in presenter.
Usage
get_piped_name(object, default_name = "Table")
Arguments
object
an object
default_name
string Attempts to return this string if an error occurs.
Value
string
Examples
#necessary to specify this option when using get_piped_name in knitr
options(rlang_trace_top_env = rlang::current_env())
### works if the object is piped or given as an argument
iris %>%
get_piped_name()
get_piped_name(iris)
### can even extract name from multistep pipes
iris %>%
dplyr::select(1:3) %>%
get_piped_name()
### can be placed inside other functions to capture the name and save it
find_name <- function(x){
get_piped_name() -> new_name
new_name
}
iris %>%
dplyr:select(1:3) %>%
find_name()
is_percentage
Description
is_percentage
Usage
is_percentage(x)
Arguments
x
numeric vector
Value
logical
Examples
c(.1, 0, .5) %>%
is_percentage
Create Excel
Description
Create Excel
Usage
make_excel(
df,
last_id_col = NULL,
header_word = NULL,
widths = 13,
random_color_seed = 1
)
Arguments
df
data frame
last_id_col
index of last id col
header_word
character vector of header words
widths
col widths
random_color_seed
seed for random color scheme
Value
an excel file
create excel wb
Description
create excel wb
Usage
make_excel_wb(
wb = NULL,
object,
last_id_col = NULL,
header_word = NULL,
widths = 13,
random_color_seed = 1
)
Arguments
wb
wb
object
object
last_id_col
index of last id col
header_word
character vector of header words
widths
col widths
random_color_seed
seed for random color scheme
Value
excel wb object
Make Flextable
Description
Turns a data frame into a flextable
Usage
make_flextable(
df,
header_words = NULL,
last_id_col = NULL,
merge_col_indices = NULL,
dbl_digits = 2,
theme = c("zebra_blue", "zebra_gold", "tron", "vader", "vanilla", "booktabs",
"alafoli")
)
Arguments
df
data frame
header_words
header words. Takes a character vector of header words. will be automatically generate via a heuristic if left NULL. can be completely disabled by the string "disable"
last_id_col
last id col
merge_col_indices
merge specific column indices
dbl_digits
integer. how many trailing digits should be displayed on dbls
theme
string to choose a preselected theme
Value
a flextable
Make pivot table
Description
If col2 is not supplied, will make a frequency table for 1 column.
Usage
make_pivot_table(
tbl,
col1,
col2 = NULL,
show_totals = TRUE,
show_percentages = c("none", "all", "row", "col"),
show_chi_test = FALSE,
theme = c("zebra_blue", "zebra_gold", "tron", "vader", "vanilla", "booktabs",
"alafoli"),
tbl_nm = NULL,
arrange_desc = TRUE
)
Arguments
tbl
a data frame to pivot
col1
unquoted col 1
col2
unquoted col 2
show_totals
logical; show row and col totals
show_percentages
string; denominator to use when calculating percentages
show_chi_test
logical; show results of chi squared test in footnote
theme
string to choose a predefined theme
tbl_nm
string to name table. If not given, automatically defaults to table name.
arrange_desc
param for single col pivot table. if True arranges table by decreasing n size
Value
a flextable
Send Table to Powerpoint
Description
A table can be piped in to this function to be sent to a new ppt slide. Can be called with no arguments, then a new ppt is created named after the table. If output_file is specified, table is sent to a new slide on an existing powerpoint.
Usage
make_powerpoint(
tbl,
output_file = NULL,
layout = "Two Content",
master = "Office Theme",
show = TRUE
)
Arguments
tbl
a data frame, flextable, or a list thereof
output_file
path to existing ppt
layout
master layout
master
master theme
show
logical to open the ppt
Value
none
Make a simple excel
Description
Export a file to excel with minimal formatting and minimal effort.
Usage
make_simple_excel(object, show = TRUE)
Arguments
object
a data frame or list thereof
show
logical. open excel upon completion?
Value
an .xlsx file
Pivot Summary
Description
Wrapper around base r 't()' that returns a tibble. Transposes a data frame, intended for use on the output of a dplyr::summarize operation
Usage
pivot_summary(sumr, ...)
Arguments
sumr
A tibble
...
an optional tidyselect specification of grouping columns to pivot
Details
for an ungrouped summarize, ... argument can be left empty for a grouped summarize, use column names or tidyselect to pivot the group names. Multiple groups will be concatenated before pivoting.
Value
a tibble
style_header_sequence
Description
style_header_sequence
Usage
style_header_sequence(header_word, object, id_col_range, wb, sheet)
Arguments
header_word
header words
object
object
id_col_range
id col range
wb
wb
sheet
sheet
Value
excel headers