Learn R Programming

Purpose

The goal of tidytidbits is to complement the environment provided by the tidyverse packages with a set of higher-level functions within the scope of data analysis and plotting.

Installation

Install from CRAN:

install.packages("tidytidbits")

Or install the latest git version from bitbucket:

devtools::install_bitbucket("mwiesweg/tidytidbits")

Components

The following areas are covered:

  • methods designed for use in a dplyr pipeline
    • formatting columns: format_numbers_at, format_p_values_at, and the corresponding generic tools as_formatted_number, as_formatted_p_value, as_percentage_label
    • adding data analysis results as new columns: count_by, add_prop_test
    • cross tabulation in a pipeline: cross_tabulate
    • lumping rows of a data frame by a count: lump_rows, and the corresponding generic tool lump
    • appending and prepepnding in a pipe with different semantics: append_object, prepend_object
    • lower-level pipeline tools: add_summary, add_summary_by, execute_if, execute_in_pipeline, interlude
  • convenience methos to rename and reorder a factor: rename_reorder_factor, rename_factor, order_factor_by
  • vectorised and non-vectorised methods implementing usefuls notions about NA and logical values: all_or_all_na, any_or_all_na, are_true, equal_including_na, falsy, invalid, true_or_na, truthy, valid
  • vectorised methods dealing with data frame columns potentially containing NA values: first_non_nas, first_not, first_not_na, first_which_not_na, which_non_na
  • a vectorised lookup method for use with dictionary-like vectors: lookup and its type-specific variants
  • some accessors for use with purrr's pluck or the additionally provided pluck_vector: name_contains, named, value_contains
  • generic tools: invert_value_and_names, str_locate_match
  • dealing with sequential duplicates: sequential_duplicates, replace_sequential_duplicates
  • for plotting:
    • conveniently saving a plot from a pipe: save_pdf, save_png
    • convenience methods for safe directory generation: prepare_path, prepare_directory
    • convenience method giving frequently used paper sizes: dinA_format, dinA_height, dinA_width
    • convenience method to create a named palette: named_palette and for creating a qualitative palette with many entries: iwanthue_palette
  • a notion of having a method which provides its local variables for reuse in other methods: local_variables and the corresponding source_variables
  • a python-style tuple-assignment implementation g(a, b) %=% function_returning_vector_of_two_elements()
  • some low-level methods utilizing rlang features: eval_unquoted, expression_list, print_deparsed, quosure_list, symbol_as_quosure, symbol_string_list, syntactically_safe

Copy Link

Version

Install

install.packages('tidytidbits')

Monthly Downloads

494

Version

0.3.2

License

GPL-3

Maintainer

Marcel Wiesweg

Last Published

March 16th, 2022

Functions in tidytidbits (0.3.2)

equal_including_na

Compare vectors, treating NA like a value
first_not_na

First argument that is not NA
save_pdf

Save plot as PDF
lump_rows

Lump rows of a tibble
named_palette

Named color palette
eval_unquoted

Execute code after tidy evaluation
save_png

Save plot as PNG
first_which_non_na_at

Row-wise first index of column that is not NA
identity_order

Ordering function: identity order
format_p_values_at

Format numeric columns for display
all_or_all_na

All() giving NA only if all values are NA
expression_list

Extract symbols from an expression of symbols and operators
count_at

Count by multiple variables
contingency_table_by

Create data frame formed like a contingency-table
first_non_nas_at

Row-wise first value that is not NA
first_not

First argument that does not equal a given value
count_by

Count according to grouping
dina

The DIN A paper formats
local_variables

"Variable generating" functions
order_factor_by

Reorder a factor
invert_value_and_names

Inverting name and value
invalid

A notion of valid and invalid
first_which_not_na

First which() is not na
format_numbers_at

Format numeric columns for display
first_non_nas

Row-wise first value which is not NA
pluck_vector

Pluck with simplified return value
prepare_directory

Directory creation
replace_sequential_duplicates

Replace sequential duplicates
rename_reorder_factor

Rename and reorder a factor.
sequential_duplicates

Detect sequential duplicates
str_locate_match

Combine str_match and str_locate
lookup

Lookup in a dictionary
prepare_path

Directory creation and file path concatenation
prepend_object

Prepending in a pipe, never unlisting
truthy

A python / javascript-like "truthy" notion
true_or_na

Test for logical true or NA
tuple_assignment

Infix operator for python-style tuple assignment
orderer_function_from_sorted_vectors

Orderer function for complex sorting
print_deparsed

Print deparsed language
lookup_function_from_dict

Creating a lookup function from dictionary
lump

Generic lumping
syntactically_safe

Syntactically safe names
symbol_as_quosure

Make quosure from symbol
with_value_containing

Slice by value
rename_factor

Rename a factor.
with_name

Slice by name
which_non_na

Get indices of non-NA values
as_formatted_p_value

Formatting p values
are_true

Vectorised conversion to logical, treating NA as False
categorical_test_by

Categorical test in a pipe
contingency_table_as_matrix

Convert contingency table to classical R matrix
add_prop_test

Add results of prop.test to data frame
any_or_all_na

Any() giving NA only if all values are NA
as_formatted_number

Format numeric value for output
as_percentage_label

Format as percentage for output
append_object

Appending in a pipe, never unlisting