Skip to contents

gentleman Package

gentleman-package gentleman
gentleman: Helpers for Data Preparation, Descriptives, Models, & Publication

Datasets

df
Simulated cross-lagged dataset

Data Preparation

add_composites()
Add composites (item means)
add_vars_from_one_df_to_another()
Add variables from one data.frame to another
cast()
Cast variables of one type to another
contr.dummy_or_effect()
Contrasts for factors using effect coding (when k > 2) or dummy coding (when k = 2)
dichotomize()
Dichotomize by picking value returned by a function
get_fuzzy_match()
Fuzzy-match strings
group_some_factor_levels()
Combine some factor levels using a map
make_factors_into_effect_codes()
Generates effect codes for factors
make_numeric_if_possible()
Make numeric if possible
recode_using_excel_map()
Recode values using Excel map (lookup table)
recode_values_to_NA()
Recode values to NA
remove_blank_factor_levels()
Remove blank factor levels
remove_empty_rows() remove_empty_cols()
Remove empty rows or columns
remove_factors_with_too_many_levels()
Remove factors with too many levels
remove_non_ascii_from_df()
Remove non-ASCII characters from data.frame
remove_outliers()
Flag and remove outliers
remove_vars_with_too_many_missing()
Remove variables with too many missing
rescale_min_max()
Rescale using min-max normalization
reverse_code()
Reverse-code numeric variables
scale_and_combine()
Combine numeric variables into one
standardize()
Standardize all numeric variables in a data.frame
to_long()
Pivot data.frame from wide to long
transpose_df()
Transpose data.frame
winsorize()
Winsorize variables

Descriptive Statistics

ana_fn_aov()
Returns p-values from ANOVA for specified vars and grouping variable
ana_fn_chisq()
Returns p-values from Chi-square tests for specified vars and grouping variable
ana_fn_rm_aov()
Returns p-values from repeated-measures (RM) ANOVA for specified vars and grouping (time) variable
compare_pairs_of_vars()
Compares pairs of variables using matched-pairs t-tests
format_p()
Format p-values with 3 decimals, no leading 0s, and < .001
get_desc_table()
Get a table of descriptive statistics for numeric or factor variables
get_desc_time()
Get a table of descriptive statistics using RM-ANOVA for numeric variables
get_sig_differences_between_groups()
Get variables for which a group difference exists
plot_density_by_groups()
Plot density by groups
tbl_fn_fac()
Internal, generic function to get summary table for factor variables
tbl_fn_num()
Internal, generic function to get summary table for numeric variables

Models

compare_sig_effects_in_two_pub_tables()
Compare significant effects from two publication tables
decompose_interaction()
Decompose 2-way (x1*x2) interaction
get_crosslagged_model()
Generate lavaan syntax for cross-lagged model
get_fmodel()
Get model object(s) using formula interface
get_lavaan_interaction_plot()
Get interaction plot for lavaan model
get_measurement_model()
Generate lavaan syntax for measurement model
get_mediation_model()
Generate lavaan syntax for mediation model
get_mediation_model_2level()
Generate lavaan syntax for 2-level mediation model
get_mediation_model_3wave()
Generate lavaan syntax for 3-wave longitudinal mediation model
get_moderated_mediation_model()
Generate lavaan syntax for moderated mediation
get_qca()
Run qualitative comparative analysis (QCA)
get_sig_effects_from_pub_table()
Extract significant effects from a publication table
make_pub_table_from_broom_tidy()
Generate publication table from broom::tidy summaries
make_pub_table_from_lavaan_models()
Generate publication table from lavaan models

Clusters

add_cluster_assignment()
Add cluster with iterative variable selection
calc_cluster_importances()
Calculate variable importances in clustering
get_cluster()
Get cluster assignment using Gower distance matrix

Machine Learning

add_predictions_from_automl()
Add predictions from an AutoML object to a test set
add_target_back_to_test_set_from_ref_table()
Add target values back in the test set
get_automl_config()
Create configuration object for running AutoML
get_automl_model()
Run an H2O AutoML model
init_h2o()
Initialize a local H2O cluster
keep_only_vars_in_both_train_and_test()
Remove variables from train and test sets when they are unique
plot_and_print_variable_importances()
Plot and print variable importances from an AutoML model
remove_target_from_test_and_add_ref_to_env()
Remove target from test set and back up values in reference table
run_automl_pipeline()
Run a full AutoML pipeline
scale_numeric_features_in_train_and_test()
Scale numeric features in train and test sets
ship_train_and_test_to_h2o()
Send train-test data.frames to H2O cluster
ttsplit()
Split data.frame into training and test sets

Logger

get_git_commit()
Retrieve current git commit information
get_logger()
Create a logger
logtext()
Log output to text file

Helpers

copy() copy2() copy3()
Wrappers for writing a data.frame to clipboard or to disk
empty_df()
Create empty data.frame with column names
get_all_pairs()
Get all possible pairs from vector
get_all_pairs_with_op()
Helper function to generate pairs with an operator separator
make_df_from_named_list()
Combine rows of named list of data.frames
`%P%` `%p%` `%N%` `%C%` `%c%`
Pasting operators
replace_in_nested_list()
Replace values in (possibly nested) list of vectors
replace_in_vector()
Replace all occurrences of a value in a vector and replace
replace_in_vector_at_position()
Replace vector element at given position with value
substr_right()
Substring character from the right side
view()
Alias for utils::View()