January 2022
January 1
If you use {dplyr} and {tidyr} π¦s to wrangle data, you may wish to see some feedback about what different operations did, especially in long piped chains.
β R Function A Day (@rfunctionaday) January 1, 2022
The "print and pipe" operator (%P>%) from {ViewPipeSteps} π¦ does this πhttps://t.co/izehRpk23g#rstats #DataScience pic.twitter.com/jEev5v27te
January 2
Inspired by other popular languages (C++, JavaScript, Python, etc.), you may also wish to use arithmetic operators in R that modify objects in place.
β R Function A Day (@rfunctionaday) January 2, 2022
The operator family from {infix} π¦ provide these! πhttps://t.co/LXJmDRYAfQ#rstats #DataScience pic.twitter.com/e4AKp7a6BF
January 3
Bar charts are a good way to visualize categorical data, but making a well-labelled bar chart can be time-consuming.
β R Function A Day (@rfunctionaday) January 3, 2022
The {PlotXTabs2} function from {CGPfunctions} π¦ easily produces this chart (with additional statistical details)!
https://t.co/Ig9tgpd9Gu#rstats #DataScience pic.twitter.com/kZBxlLPBZ2
January 4
Sometimes you need to check if a remote computer or web server is up and running.
β R Function A Day (@rfunctionaday) January 4, 2022
You can do so in R using the {ping} function from {pingr} π¦! πhttps://t.co/ahm9IdRc3y#rstats #DataScience pic.twitter.com/FPZiRwyz0s
January 5
Sometimes you wish to remove only certain rows or columns that are completely empty instead of partly empty.
β R Function A Day (@rfunctionaday) January 5, 2022
The {remove_empty_*} function family from {janitor} π¦ do exactly this! π§Ήhttps://t.co/j1RAFZv4pY#rstats #DataScience pic.twitter.com/QHb1bDzHzB
January 6
Kaplan-Meier estimates of survival curves can help infer differences in survival times between compared groups.
β R Function A Day (@rfunctionaday) January 6, 2022
The {ggsurvplot} function from {survminer} π¦ plots such curves with rich details! πhttps://t.co/n25xxlgZiV#rstats #DataScience pic.twitter.com/H1FbLNSlhv
January 7
A Bland-Altman plot helps visually assess agreement between scores of any kind (psychological questionnaires, chemical assays, etc.).
β R Function A Day (@rfunctionaday) January 7, 2022
The {BAC_plot} function from {ufs} π¦ easily creates them with elegant defaults! ππhttps://t.co/zl7vSzwe26#rstats #DataScience pic.twitter.com/g73a0A6k11
January 8
Sometimes we may need to edit images in R, e.g.Β changing transparency, spatial anti-aliasing, converting to black and white, etc.
β R Function A Day (@rfunctionaday) January 8, 2022
The {image_convert} function from {magick} π¦ allows many options for doing so! πΈhttps://t.co/ald6jeDtOe#rstats #DataScience pic.twitter.com/ZV74ynzCtN
January 9
To ensure reproducibility of R script, you may wish it to download needed package versions on a certain date.
β R Function A Day (@rfunctionaday) January 9, 2022
The {create_checkpoint} function from {checkpoint} π¦ creates a local library with the needed package versions! πhttps://t.co/L8uArRuRiN
#rstats #DataScience pic.twitter.com/T6R9b5W5yY
January 10
PCA is a popular dimensionality reduction technique and sometimes you may wish to reports its results in a report.
β R Function A Day (@rfunctionaday) January 10, 2022
The {tab_pca} function from {sjPlot} π¦ produces publication-ready HTML table for PCA with elegant defaults! πhttps://t.co/mvakHooBSf#rstats #DataScience pic.twitter.com/tULXxnRShU
January 11
A list is a non-atomic vector, and sometimes you may wish to convert (or flatten) it to an atomic one.
β R Function A Day (@rfunctionaday) January 11, 2022
The {flatten} function family from {purrr} π¦ provides helpers to do this with type stability! πhttps://t.co/tMAS8S8RcM#rstats #DataScience pic.twitter.com/NA7zvA2Rtb
January 12
Across disciplines (physics, engineering, etc.), a quiver plot helps visualize vector fields as arrows, and we may need to create such a plot in R.
β R Function A Day (@rfunctionaday) January 12, 2022
The {geom_quiver} function from {ggquiver} π¦ offers just the geometric layer! πͺhttps://t.co/DNwPEmLFDe#rstats #DataScience pic.twitter.com/a2RZuXtKX6
January 13
Filename extensions (.py, .csv, .pdf, etc.) decide the characteristics and intended usage of files, and we may wish to work with them further in R.
β R Function A Day (@rfunctionaday) January 13, 2022
The {*_ext} function family in {xfun} π¦ provides helpers to do so! πhttps://t.co/Qq8IQsMb6Q#rstats #DataScience pic.twitter.com/l47PKMvzrL
January 14
Sometimes you want to quickly compute and visualize frequencies for all categorical variables in the data.
β R Function A Day (@rfunctionaday) January 14, 2022
The {inspect_cat} function from {inspectdf} π¦ does so, while labeling most frequent levels and highlighting missing data! πhttps://t.co/loDxpvrDGP#rstats #DataScience pic.twitter.com/aamrTwLhQh
January 15
Although often you can easily read data from a single CSV file, sometimes you have to read a dataset stored in one of the Excel spreadsheets.
β R Function A Day (@rfunctionaday) January 15, 2022
The {read_xlsx} function from {readxl} π¦ provides an easy syntax to do so! πhttps://t.co/TE7GJQVSS8#rstats #DataScience pic.twitter.com/XTqST8rbou
January 16
To save space, IP addresses are often stored as integers, and if we receive such data, we may wish to convert them to the familiar human-readable form.
β R Function A Day (@rfunctionaday) January 16, 2022
The {integer_to_ip} function from {ipaddress} π¦ makes this conversion easy! πΈhttps://t.co/IqK3ihOIjc#rstats #DataScience pic.twitter.com/CvDYbKPuej
January 17
A horizon plot is a compact time-series data visualization to plot and compare different moving values.
β R Function A Day (@rfunctionaday) January 17, 2022
The {geom_horizon} function from {ggHoriPlot} π¦ provides just the geometric layer! β¬οΈβ¬οΈhttps://t.co/NSA3RYIoiE#rstats #DataScience pic.twitter.com/7uqC45DQOf
January 18
Sometimes, especially in the context of statistical modeling, there might be infinite or NaN's present in outputs that we may wish to replace with NAs.
β R Function A Day (@rfunctionaday) January 18, 2022
The {zap_inf} helper function from {sjmisc} π¦ does exactly this! βΎhttps://t.co/mrWehQheOi#rstats #DataScience pic.twitter.com/CL7qiucGd7
January 19
Python dictionary is an unordered data type with key-value pairs that allows accessing values, not by indexing, but via unique keys.
β R Function A Day (@rfunctionaday) January 19, 2022
The {py_dict} function from {reticulate} π¦ gives you access to this data type in R! πhttps://t.co/stxGhcedjI#rstats #DataScience pic.twitter.com/C7jiezmfad
January 20
Sometimes you may wish to include some patterns or images in plots for enhanced storytelling.
β R Function A Day (@rfunctionaday) January 20, 2022
The {image} or {pattern} function family from {patternplot} π¦ provides a way to do so! βοΈhttps://t.co/lRhdnmbQoQ#rstats #DataScience pic.twitter.com/S1ze86OJTk
January 21
Serialization changes objects to a byte stream that can be saved to a binary file, while deserializing does the reverse.
β R Function A Day (@rfunctionaday) January 21, 2022
The {q*} function family from {qs} π¦ provides a performant way to serialize or deserialize any R object! β‘οΈhttps://t.co/i8BNgtAQWw#rstats #DataScience pic.twitter.com/5yTJWk3z5Z
January 22
Visualizing data along an Archimedean spiral can efficiently reveal periodic patterns in time series data.
β R Function A Day (@rfunctionaday) January 22, 2022
The {spiral_*} function family from {spiralize} π¦ draws such spiral plots flexibly! πhttps://t.co/5vybsvWv2e#rstats #DataScience pic.twitter.com/c168IWhcXL
January 23
While working in a piped workflow, if you need to extract a single column, the syntax to do so can be a bit cumbersome.
β R Function A Day (@rfunctionaday) January 23, 2022
The {pull} function from {dplyr} π¦ provides a more readable syntax to this end! πhttps://t.co/rCT1vcMZzX#rstats #DataScience pic.twitter.com/vEs2cc7Lw8
January 24
If we need to bind multiple dataframes by rows, we may first wish to check if this can be done successfully.
β R Function A Day (@rfunctionaday) January 24, 2022
The {compare_df_cols} function from {janitor} π¦ provides a summary of data types to check this! ππhttps://t.co/88zYQFdIWa#rstats #DataScience pic.twitter.com/kSCLESOBP9