Learn R Programming

lares

R Package for Analytics and Machine Learning

R package built to automate, improve, and speed everyday Analysis and Machine Learning tasks. With a wide variety of family functions like Machine Learning, data cleaning and processing, EDA, Investment, NLP, Queries, Scrappers, API interactions, lares helps the analyst or data scientist get quick, reproducible, robust results, without the need of repetitive coding nor extensive programming skills. Feel free to install, use, and/or comment on any of the code and functionalities. And if you are also colourblind, be sure to check the colour palettes!

Don't hesitate to contact me, and please when you do, let me know where did you first hear from the library and which family of functions you are most interested in.

Installation

## CRAN VERSION
install.packages("lares")

## DEV VERSION
# If you don't have remotes yet, run: install.packages('remotes')
remotes::install_github("laresbernardo/lares")
# Full installation with recommended dependencies (takes more time)
remotes::install_github("laresbernardo/lares", dependencies = TRUE)

Windows users: you MAY have to install RTools before installing the dev version. Download it here.

See the library in action!

AutoML Simplified Map h2o_automl()

Insights While Understanding

To get insights and value out of your dataset, first you need to understand its structure, types of data, empty values, interactions between variables... corr_cross() and freqs() are here to give you just that! They show a wide perspective of your dataset content, correlations, and frequencies. Additionally, with the missingness() function to detect all missing values and df_str() to break down you data frame's structure, you will be ready to squeeze valuable insights out of your data. If you'd like to go deeper, try the x2y(), lasso_vars() and tree_var() to use Machine Learning to detect patterns, predictive powers, and variables importance.

Kings of Data Mining

My favourite and most used functions are freqs(), distr(), and corr_var(). In this RMarkdown you can see them in action. Basically, they group and count values within variables, show distributions of one variable vs another one (numerical or categorical), and calculate/plot correlations of one variables vs all others, no matter what type of data you insert.

If there is space for one more, I would add ohse() (One Hot Smart Encoding), which has made my life much easier and my work much valuable. It converts a whole data frame into numerical values by making dummy variables (categoricals turned into new columns with 1s and 0s, ordered by frequencies and grouping less frequent into a single column) and dates into new features (such as month, year, week of the year, minutes if time is present, holidays given a country, currency exchange rates, etc).

What else is there?

You can check all active functions and documentations here or type lares:: in RStudio and you will get a pop-up with all the functions that are currently available within the package. You might also want to check the whole documentation by running help(package = "lares") in your RStudio or in the Online Official Documentation. Remember to check the families and similar functions on the See Also sections as well.

Getting further help

If you need help with any of the functions when using RStudio, use the ? function (i.e. ?lares::function) and the Help tab will display a short explanation on each function and its parameters. You might also be interested in the online documentation to check all functions and parameters.

If you encounter a bug, please share with me a reproducible example on Github issues and I'll take care of it. For inquiries, and other matters, you can contact me on LinkedIn anytime!

Copy Link

Version

Install

install.packages('lares')

Monthly Downloads

6,184

Version

5.3.1

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Bernardo Lares

Last Published

July 4th, 2025

Functions in lares (5.3.1)

crosstab

Weighted Cross Tabulation
date_cuts

Convert Date into Year + Cut
date_feats

One Hot Encoding for Date/Time Variables (Dummy Variables)
dalex_local

DALEX Local
clusterOptimalK

Visualize K-Means Clusters for Several K Methods
dalex_variable

DALEX Partial Dependency Plots (PDP)
clusterKmeans

Automated K-Means Clustering + PCA/t-SNE
dalex_residuals

DALEX Residuals
encrypt_file

File Encryption and Decryption (AES-256-CBC)
distr

Compare Variables with their Distributions
balance_data

Balance Binary Data by Resampling: Under-Over Sampling
bind_files

Bind Files into Dataframe
fb_report_check

Facebook API Report Status Check
fb_token

Facebook's Long-Life User API Token
file_name

Extract file raw name and type from file names
forecast_arima

ARIMA Forecast
errors

Calculate Continuous Values Errors
freqs

Frequencies Calculations and Plot
fb_rf

Facebook Reach and Frequency API
db_download

Download/Import Dropbox File by File's Name
formatHTML

Format a string text as markdown/HTML
corr_var

Correlation between variable and dataframe
cran_logs

Download and plot daily downloads of CRAN packages
fb_creatives

Facebook Creatives API
freqs_plot

Combined Frequencies Plot for Categorical Features
fb_ads

Facebook Ads API
dont_sleep

Prevent Computer from Sleeping by Simulating Mouse Activity
get_currency

Download Historical Currency Exchange Rate
gemini_ask

Gemini API Interaction with R
get_credentials

Load Credentials from a YML File
formatColoured

Print Coloured Messages
gain_lift

Cumulative Gain, Lift and Response
get_tweets

Get Tweets
ci_var

Confidence Intervals on Dataframe
export_results

Export h2o_automl's Results
h2o_explainer

DALEX Explainer for H2O
cleanText

Clean text strings automatically
db_upload

Upload Local Files to Dropbox
df_str

Dataset columns and rows structure
fb_accounts

Facebook Ad Accounts
etf_sector

ETF's Sectors Breakdown
dfr

Results for AutoML Predictions
get_mp3

Download MP3 from URL
export_plot

Export ggplot2, gridExtra, or any plot object into rendered file
grepm

Pattern Matching for Any or All Multiple Matches
h2o_shap

SHAP values for H2O Models
freqs_df

Plot for All Frequencies on Dataframe
freqs_list

Frequencies on Lists and UpSet Plot
gg_fill_customs

Custom fill, colour and text colours for ggplot2
h2o_predict_MOJO

Calculate predictions of h2o Models
importxlsx

Import Excel File with All Its Tabs
lares-exports

Pipe operator
h2o_automl

Automated H2O's AutoML
install_recommended

Install/Update Additional Recommended Libraries
impute

Impute Missing Values (using MICE)
lares

Analytics, Data Mining & Machine Learning Sidekick
haveInternet

Internet Connection Check
h2o_results

Automated H2O's AutoML Results
listfiles

List files in a directory
list_cats

List categorical values for data.frame
glued

Interpolate a string [glue wrapper]
font_exists

Check if Font is Installed
fb_process

Paginate and Process Facebook's API Results
fb_insights

Facebook Insights API
removenacols

Remove/Drop Columns in which ALL or SOME values are NAs
mplot_density

Density plot for discrete and continuous values
mplot_conf

Confussion Matrix Plot
maze_solve

Maze Solver, inspired by Micromouse competitions
markdown2df

Convert markdown string tables to data.frame
mplot_cuts

Cuts by quantiles for score plot
readGS

Google Sheets Reading and Writing (API v4)
mplot_cuts_error

Cuts by quantiles on absolute and percentual errors plot
mplot_response

Cumulative Response Plot
cache_write

Cache Save and Load (Write and Read)
ip_data

Scrap data based on IP address
mplot_topcats

Top Hit Ratios for Multi-Classification Models
bring_api

Get API (JSON) and Transform into data.frame
iter_seeds

Iterate Seeds on AutoML
json2vector

Convert Python JSON string to R vector (data.frame with 1 row)
h2o_selectmodel

Select Model from h2o_automl's Leaderboard
mplot_metrics

Model Metrics and Performance Plots
mplot_importance

Variables Importances Plot
lares_logo

Print lares R library Logo
mplot_roc

ROC Curve Plot
normalize

Normalize Vector
mplot_gain

Cumulative Gain Plot
lares_pal

Personal Colours Palette
mplot_full

MPLOTS Score Full Report Plots
corr

Correlation table
noPlot

Plot Result with Nothing to Plot
msplit

Split a dataframe for training and testing sets
corr_cross

Ranked cross-correlation across all variables
loglossBinary

Logarithmic Loss Function for Binary Models
model_preprocess

Automate Data Preprocess for Modeling
robyn_xmodels

Cross-MMM Budget Optimization across Models
dft

Titanic Dataset
mplot_lineal

Linear Regression Results Plot
mail_send

Send Emails with Attachments (POST)
robyn_hypsbuilder

Robyn: Generate default hyperparameters
outlier_zscore

Outliers: Z-score method
dist2d

Distance from specific point to line
outlier_zscore_plot

Outliers: Z-score method plot
plot_survey

Visualize Survey Results
plot_chord

Chords Plot
mplot_splits

Split and compare quantiles plot
plot_cats

Plot All Categorical Features (Frequencies)
plot_palette

Plot Palette Colours
reduce_tsne

Reduce Dimensionality with t-SNE
myip

What's my IP?
ngrams

Build N-grams and keep most frequent
remove_stopwords

Remove stop-words and patterns from character vector
shap_var

SHAP-based dependence plots for categorical/numerical features (PDP)
filesGD

Google Drive Files (API v4)
ohse

One Hot Smart Encoding (Dummy Variables)
scale_x_comma

Axis scales format
move_files

Move files from A to B
queryDB

PostgreSQL Queries on Database (Read)
quants

Calculate cuts by quantiles
spread_list

Spread list column into new columns
textTokenizer

Tokenize Vectors into Words
scrabble_dictionary

Scrabble: Dictionaries
textFeats

Create features out of text
statusbar

Progressive Status Bar (Loading)
outlier_tukey

Outliers: Tukey’s fences
quiet

Quiet prints and verbose noise
robyn_marginal

Robyn: Marginal Performance (mROAS & mCPA) [Experimental]
gtrends_related

Google Trends: Related and Time Plots
files_functions

List all functions used in R script files by package
queryGA

Queries on Google Analytics
plot_df

Plot Summary of Numerical and Categorical Features
slackSend

Send Slack Message (Webhook)
tic

Stopwatch to measure timings in R
tree_var

Recursive Partitioning and Regression Trees
theme_lares

Theme for ggplot2 (lares)
topics_rake

Keyword/Topic identification using RAKE
plot_nums

Plot All Numerical Features (Boxplots)
gpt_ask

ChatGPT API Interaction with R
try_require

Check if Specific Package is Installed
trim_mp3

Trim MP3 Audio File
read.file

Read Files Quickly (Auto-detected)
robyn_modelselector

Robyn: Model Selection by Weighted Criteria Scores
seq_surnames

Surnames Order Sequence
sentimentBreakdown

Sentiment Breakdown on Text
sudoku_solver

Solve Sudoku Puzzles
stocks_file

Build a Personal Investing Portfolio Report
stocks_quote

Download Stocks Historical and Current Values
warnifnot

Test the Truth of R Expressions and Warn
updateLares

Update the library (dev or CRAN version)
weighted_value

Calculate weighted stock values using FIFO/LIFO
splot_summary

Investing Portfolio Reporting Plots
vector2text

Convert a vector into a comma separated text
year_month

Convert Date into Year-Month, Year-Quarter or Year-Week Format
zerovar

Zero Variance Columns
wordle_check

Wordle Game Validation
x2y

Ranked Predictive Power of Cross-Features (x2y)
grepl_letters

Pattern Matching for Letters considering Blanks
gpt_prompter

Structured Prompt Builder for LLM (ChatGPT)
holidays

Holidays in your Country
image_metadata

Get Meta Data from Image Files
left

Left or Right N characters of a string
lasso_vars

Most Relevant Features Using Lasso Regression
missingness

Calculate and Visualize Missingness
reduce_pca

Reduce Dimensionality with PCA
model_metrics

Model Metrics and Performance
num_abbr

Abbreviate or dis-abbreviate numerical values
ohe_commas

One Hot Encoding for a Vector with Comma Separated Values
plot_timeline

Plot timeline as Gantt Plot
target_set

Set Target Value in Target Variable
replacefactor

Replace Factor Values
replaceall

Replace Values With
robyn_performance

Robyn: Dynamic Performance and Contribution Report
prophesize

Facebook's Prophet Forecast
rtistry_sphere

Generative Art: Sphere XmodY
textCloud

Wordcloud Plot
what_size

Calculate the size of any R object or directory
winsorize

Outliers: Winsorize
chr2num

Check character values for date/numeric/logical and change datatype
check_opts

Validate inputs (attributions, options, ...)
ci_lower

Lower/Upper Confidence Intervals
categ_reducer

Reduce categorical values
autoline

New Line Feed for Long Strings (Wrapper)
ROC

AUC and ROC Curves Data
conf_mat

Confussion Matrix
clusterVisualK

Visualize K-Means Clusters for Several K