Learn R Programming

⚠️There's a newer version (5.3.1) of this package.Take me there.

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,679

Version

5.2.2

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Bernardo Lares

Last Published

May 18th, 2023

Functions in lares (5.2.2)

categ_reducer

Reduce categorical values
ci_var

Confidence Intervals on Dataframe
check_opts

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

Lower/Upper Confidence Intervals
cache_write

Cache Save and Load (Write and Read)
conf_mat

Confussion Matrix
clusterKmeans

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

Visualize K-Means Clusters for Several K Methods
crosstab

Weighted Cross Tabulation
corr

Correlation table
cleanText

Clean text strings automatically
clusterVisualK

Visualize K-Means Clusters for Several K
cran_logs

Download and plot daily downloads of CRAN packages
corr_cross

Ranked cross-correlation across all variables
corr_var

Correlation between variable and dataframe
date_cuts

Convert Date into Year + Cut
dalex_residuals

DALEX Residuals
dalex_variable

DALEX Partial Dependency Plots (PDP)
df_str

Dataset columns and rows structure
daily_portfolio

Daily Portfolio Dataframe
db_upload

Upload Local Files to Dropbox
dalex_local

DALEX Local
daily_stocks

Daily Stocks Dataframe
date_feats

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

Download/Import Dropbox File by File's Name
errors

Calculate Continuous Values Errors
dist2d

Distance from specific point to line
etf_sector

ETF's Sectors Breakdown
dft

Titanic Dataset
distr

Compare Variables with their Distributions
dfr

Results for AutoML Predictions
export_plot

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

Facebook Ad Accounts
fb_ads

Facebook Ads API
export_results

Export h2o_automl's Results
fb_report_check

Facebook API Report Status Check
fb_process

Paginate and Process Facebook's API Results
file_name

Extract file raw name and type from file names
fb_creatives

Facebook Creatives API
filesGD

Google Drive Files (API v4)
fb_rf

Facebook Reach and Frequency API
fb_token

Facebook's Long-Life User API Token
files_functions

List all functions used in R script files by package
fb_insights

Facebook Insights API
removenacols

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

Frequencies on Lists and UpSet Plot
font_exists

Check if Font is Installed
gain_lift

Cumulative Gain, Lift and Response
formatColoured

Print Coloured Messages
freqs_df

Plot for All Frequencies on Dataframe
freqs

Frequencies Calculations and Plot
formatHTML

Format a string text as markdown/HTML
forecast_arima

ARIMA Forecast
get_credentials

Load Credentials from a YML File
gtrends_related

Google Trends: Related and Time Plots
glued

Interpolate a string [glue wrapper]
readGS

Google Sheets Reading and Writing (API v4)
freqs_plot

Combined Frequencies Plot for Categorical Features
gpt_ask

ChatGPT API Interaction with R
gg_fill_customs

Custom fill, colour and text colours for ggplot2
get_tweets

Get Tweets
get_currency

Download Historical Currency Exchange Rate
get_mp3

Download MP3 from URL
h2o_predict_API

H2O Predict using API Service
h2o_results

Automated H2O's AutoML Results
h2o_predict_binary

H2O Predict using Binary file
install_recommended

Install/Update Additional Recommended Libraries
h2o_predict_MOJO

H2O Predict using MOJO file
holidays

Holidays in your Country
h2o_explainer

DALEX Explainer for H2O
grepl_letters

Pattern Matching for Letters considering Blanks
h2o_automl

Automated H2O's AutoML
image_metadata

Get Meta Data from Image Files
grepm

Pattern Matching for Any or All Multiple Matches
h2o_predict_model

H2O Predict using H2O Model Object
h2o_selectmodel

Select Model from h2o_automl's Leaderboard
lares-exports

Pipe operator
json2vector

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

List files in a directory
is_url

Check if input is_* or are_*
lasso_vars

Most Relevant Features Using Lasso Regression
lares_pal

Personal Colours Palette
iter_seeds

Iterate Seeds on AutoML
loglossBinary

Logarithmic Loss Function for Binary Models
ip_data

Scrap data based on IP address
mail_send

Send Emails with Attachments (POST)
left

Left or Right N characters of a string
mplot_conf

Confussion Matrix Plot
markdown2df

Convert markdown string tables to data.frame
li_auth

OAuth Linkedin
lares

Analytics, Data Mining & Machine Learning Sidekick
mplot_cuts

Cuts by quantiles for score plot
h2o_shap

SHAP values for H2O Models
haveInternet

Internet Connection Check
lares_logo

Print lares R library Logo
missingness

Calculate and Visualize Missingness
model_metrics

Model Metrics and Performance
mplot_topcats

Top Hit Ratios for Multi-Classification Models
mplot_lineal

Linear Regression Results Plot
mplot_importance

Variables Importances Plot
mplot_metrics

Model Metrics and Performance Plots
importxlsx

Import Excel File with All Its Tabs
list_cats

List categorical values for data.frame
li_profile

Get My Personal LinkedIn Data
impute

Impute Missing Values (using MICE)
mplot_cuts_error

Cuts by quantiles on absolute and percentual errors plot
msplit

Split a dataframe for training and testing sets
model_preprocess

Automate Data Preprocess for Modeling
mplot_density

Density plot for discrete and continuous values
outlier_zscore

Outliers: Z-score method
myip

What's my IP?
mplot_gain

Cumulative Gain Plot
move_files

Move files from A to B
outlier_zscore_plot

Outliers: Z-score method plot
mplot_full

MPLOTS Score Full Report Plots
mplot_response

Cumulative Response Plot
ngrams

Build N-grams and keep most frequent
plot_palette

Plot Palette Colours
plot_survey

Visualize Survey Results
num_abbr

Abbreviate numbers
plot_df

Plot Summary of Numerical and Categorical Features
ohe_commas

One Hot Encoding for a Vector with Comma Separated Values
plot_timeline

Plot timeline as Gantt Plot
prophesize

Facebook's Prophet Forecast
mplot_splits

Split and compare quantiles plot
remove_stopwords

Remove stop-words and patterns from character vector
normalize

Normalize Vector
replaceall

Replace Values With
plot_nums

Plot All Numerical Features (Boxplots)
noPlot

Plot Result with Nothing to Plot
reduce_tsne

Reduce Dimensionality with t-SNE
mplot_roc

ROC Curve Plot
replacefactor

Replace Factor Values
plot_cats

Plot All Categorical Features (Frequencies)
ohse

One Hot Smart Encoding (Dummy Variables)
plot_chord

Chords Plot
queryGA

Queries on Google Analytics
scrabble_dictionary

Scrabble: Dictionaries
quiet

Quiet prints and verbose noise
sentimentBreakdown

Sentiment Breakdown on Text
outlier_turkey

Outliers: Tukey’s fences
quants

Calculate cuts by quantiles
splot_roi

Portfolio Plots: Daily ROI
splot_change

Portfolio Plots: Daily Change
read.file

Read Files Quickly (Auto-detected)
target_set

Set Target Value in Target Variable
splot_divs

Portfolio Plots: Dividends per Year and Quarter
splot_types

Portfolio Plots: Types of Stocks
spread_list

Spread list column into new columns
stocks_file

Get Personal Portfolio's Data
statusbar

Progressive Status Bar (Loading)
textCloud

Wordcloud Plot
splot_summary

Portfolio Plots: Total Summary
slackSend

Send Slack Message (Webhook)
scale_x_comma

Axis scales format
shap_var

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

Generative Art: Sphere XmodY
sudoku_solver

Solve Sudoku Puzzles
queryDB

PostgreSQL Queries on Database (Read)
stocks_report

Portfolio's Full Report and Email
splot_etf

Portfolio's Sector Distribution (ETFs)
updateLares

Update the library (dev or CRAN version)
reduce_pca

Reduce Dimensionality with PCA
theme_lares

Theme for ggplot2 (lares)
vector2text

Convert a vector into a comma separated text
tic

Stopwatch to measure timings in R
topics_rake

Keyword/Topic identification using RAKE
trim_mp3

Trim MP3 Audio File
tree_var

Recursive Partitioning and Regression Trees
splot_growth

Portfolio Plots: Growth (Cash + Invested)
try_require

Check if Specific Package is Installed
zerovar

Zero Variance Columns
stocks_quote

Download Stocks Historical and Current Values
wordle_check

Wordle Game Validation
winsorize

Outliers: Winsorize
x2y

Ranked Predictive Power of Cross-Features (x2y)
stocks_obj

Portfolio's Calculations and Plots
year_month

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

Test the Truth of R Expressions and Warn
what_size

Calculate the size of any R object
textFeats

Create features out of text
textTokenizer

Tokenize Vectors into Words
ROC

AUC and ROC Curves Data
bring_api

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

New Line Feed for Long Strings (Wrapper)
bind_files

Bind Files into Dataframe
balance_data

Balance Binary Data by Resampling: Under-Over Sampling