Learn R Programming

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

lares

R Package for Analytics and Machine Learning

R library 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 procesing, 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 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 from 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 LinkedIn me anytime!

Copy Link

Version

Install

install.packages('lares')

Monthly Downloads

3,658

Version

5.0.0

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Bernardo Lares

Last Published

June 3rd, 2021

Functions in lares (5.0.0)

cache_write

Cache Save and Load (Write and Read)
ci_lower

Lower/Upper Confidence Intervals
check_opts

Validate options within vector
bindfiles

Bind Files into Dataframe
bring_api

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

Attribute checker
categ_reducer

Reduce categorical values
ROC

AUC and ROC Curves Data
balance_data

Balance Binary Data by Resampling: Under-Over Sampling
autoline

New Line Feed for Long Strings (Wrapper)
corr_cross

Ranked cross-correlation across all variables
clusterVisualK

Visualize K-Means Clusters for Several K
daily_stocks

Daily Stocks Dataframe
dalex_local

DALEX Local
clusterOptimalK

Visualize K-Means Clusters for Several K Methods
db_upload

Upload Local Files to Dropbox
db_download

Download/Import Dropbox File by File's Name
corr_var

Correlation between variable and dataframe
dalex_residuals

DALEX Residuals
dalex_variable

DALEX Partial Dependency Plots (PDP)
df_str

Dataset columns and rows structure
dft

Dataset: Titanic Sub-dataset por Examples
export_results

Export h2o_automl's Results
ci_var

Confidence Intervals on Dataframe
cleanText

Clean text
dist2d

Distance from specific point to line
fb_process

Process Facebook's API Objects
fb_posts

Get Facebook's Page Posts (API Graph)
fb_insights

Facebook Insights API
freqs_plot

Combinated Frequencies Plot for Categorical Features
freqs_list

Frequencies on Lists and UpSet Plot
cleanNames

Clean title names of a data.frame/tibble object
gain_lift

Cumulative Gain, Lift and Response
fb_post

Get Facebook's Post Comments (API Graph)
fb_accounts

Facebook Ad Accounts
get_credentials

Load Credentials from a YML File
get_currency

Download Historical Currency Exchange Rate
get_mp3

Download MP3 from URL
dfr

Dataset: Results for AutoML Predictions
h2o_predict_model

H2O Predict using H2O Model Object
h2o_results

Automated H2O's AutoML Results
freqs

Frequencies Calculations and Plot
fb_creatives

Facebook Creatives API
fb_ads

Facebook Ads API
grepl_letters

Pattern Matching for Letters considering Blanks
glued

Interpolate a string [glue wrapper]
conf_mat

Confussion Matrix
gg_pie

Density plot for discrete and continuous values
gg_text_customs

Custom colours for scale_color_manual on texts [Deprecated]
freqs_df

Plot for All Frequencies on Dataframe
importxlsx

Import Excel File with All Its Tabs
image_metadata

Get Meta Data from Image Files
corr

Correlation table
h2o_predict_MOJO

H2O Predict using MOJO file
is_url

Check if input is_* or are_*
ip_data

Scrap data based on IP address
font_exists

Check if Font is Installed
clusterKmeans

Automated K-Means Clustering + PCA
crosstab

Weighted Cross Tabulation
forecast_arima

ARIMA Forecast
daily_portfolio

Daily Portfolio Dataframe
gg_fill_customs

Custom colours for scale_fill_manual [Deprecated]
gg_colour_customs

Custom colours for scale_color_manual [Deprecated]
h2o_predict_binary

H2O Predict using Binary file
lares-exports

Pipe operator
lares

Analytics, Visualization & Machine Learning Tasks Library
distr

Compare Variables with their Distributions
li_auth

OAuth Linkedin
missingness

Calculate and Visualize Missingness
left

Left or Right N characters of a string
mailSend

Send Emails with Attachments (POST)
errors

Calculate Continuous Values Errors
fb_token

Facebook's Long Life User Token
fb_rf

Facebook Reach and Frequency API
formatNum

Nicely Format Numerical Values
mplot_full

MPLOTS Score Full Report Plots
mplot_density

Density plot for discrete and continuous values
date_cuts

Convert Date into Year + Cut
date_feats

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

ETF's Sectors Breakdown
iter_seeds

Iterate Seeds on AutoML
filesGD

Google Drive Files (API v4)
file_name

Get file names without extensions
export_plot

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

Get file extensions without file names
json2vector

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

Get Tweets
gg_bars

Quick Nice Bar Plot
formatText

Format a string text as markdown/HTML
numericalonly

Select only numerical columns in a dataframe
move_files

Move files from A to B
mplot_conf

Confussion Matrix Plot
mplot_gain

Cumulative Gain Plot
mplot_importance

Variables Importances Plot
h2o_explainer

DALEX Explainer for H2O
ohe_commas

One Hot Encoding for a Vector with Comma Separated Values
files_functions

List all functions used in R script files by package
h2o_predict_API

H2O Predict using API Service
outlier_zscore

Outliers: Z-score method
outlier_zscore_plot

Outliers: Z-score method plot
msplit

Split a dataframe for training and testing sets
replacefactor

Replace Factor Values
rtistry_sphere

Generative Art: Sphere XmodY
num_abbr

Abbreviate numbers
normalize

Normalize Vector
myip

What's my IP?
impute

Impute Missing Values (using MICE)
grepm

Pattern Matching for Any or All Multiple Matches
h2o_automl

Automated H2O's AutoML
install_recommended

Install/Update Additional Recommended Libraries
removenarows

Remove/Drop Rows in which ALL or SOME values are NAs
replaceall

Replace Values With
haveInternet

Internet Connection Check
splot_summary

Portfolio Plots: Total Summary
holidays

Holidays in your Country
theme_lares

Theme for ggplot2 (lares)
splot_types

Portfolio Plots: Types of Stocks
plot_timeline

Plot timeline as Gantt Plot
remove_stopwords

Remove stop-words and patterns from character vector
removenacols

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

Facebook's Prophet Forecast
scrabble_words

Scrabble: Highest score words finder
tic

Stopwatch to measure timings in R
topics_rake

Keyword/Topic identification using RAKE
listfiles

List files in a directory
tree_var

Recursive Partitioning and Regression Trees
li_profile

Get My Personal LinkedIn Data
h2o_selectmodel

Select Model from h2o_automl's Leaderboard
h2o_shap

SHAP values for H2O Models
scale_x_comma

Axis scales format
loglossBinary

Logarithmic Loss Function for Binary Models
scrabble_dictionary

Scrabble: Dictionaries
sentimentBreakdown

Sentiment Breakdown on Text
list_cats

List categorical values for data.frame
mplot_lineal

Linear Regression Results Plot
lares_pal

Personal Colours Palette
mplot_cuts

Cuts by quantiles for score plot
mplot_cuts_error

Cuts by quantiles on absolute and percentual errors plot
mplot_response

Cumulative Response Plot
splot_roi

Portfolio Plots: Daily ROI
splot_growth

Portfolio Plots: Growth (Cash + Invested)
splot_etf

Portfolio's Sector Distribution (ETFs)
splot_change

Portfolio Plots: Daily Change
lasso_vars

Most Relevant Features Using Lasso Regression
mplot_metrics

Model Metrics and Performance Plots
mplot_roc

ROC Curve Plot
ohse

One Hot Smart Encoding (Dummy Variables)
model_metrics

Model Metrics and Performance
outlier_turkey

Outliers: Tukey<U+2019>s fences
textFeats

Create features out of text
textTokenizer

Tokenize Vectors into Words
trim_mp3

Trim MP3 Audio File
model_preprocess

Automate Data Preprocess for Modeling
try_require

Check if Specific Package is Installed
year_week

Convert Date into Year-Week (YYYY-WW)
ngrams

Build N-grams and keep most frequent
plot_cats

Plot All Categorical Features (Frequencies)
noPlot

Plot Result with Nothing to Plot
mplot_splits

Split and compare quantiles plot
plot_df

Plot Summary of Numerical and Categorical Features
mplot_topcats

Top Hit Ratios for Multi-Classification Models
zerovar

Zero Variance Columns
plot_chord

Chords Plot
plot_nums

Plot All Numerical Features (Boxplots)
queryGA

Queries on Google Analytics
quiet

Quiet prints and verbose noice
read.file

Read Files Quickly (Auto-detected)
stocks_report

Portfolio's Full Report and Email
sudoku_solver

Solve Sudoku Puzzles
winsorize

Outliers: Winsorize
readGS

Google Sheets Reading (API v4)
writeGS

Google Sheets Writing (API v4)
shap_var

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

Send Slack Message (Webhook)
spread_list

Spread list column into new columns
statusbar

Progressive Status Bar (Loading)
plot_palette

Plot Palette Colours
quants

Calculate cuts by quantiles
plot_survey

Visualize Survey Results
stocks_quote

Download Stocks Current Data
stocks_obj

Portfolio's Calculations and Plots
queryDB

PostgreSQL Queries on Database (Read)
scrabble_points

Scrabble: Tiles Points
scrabble_score

Scrabble: Word Scores
trendsRelated

Google Trends: Related Plot
trendsTime

Google Trends: Timelines Plot
stocks_file

Get Personal Portfolio's Data
stocks_hist

Download Stocks Historical Data
textCloud

Wordcloud Plot
target_set

Set Target Value in Target Variable
updateLares

Update the library (dev or CRAN version)
vector2text

Convert a vector into a comma separated text
x2y

Ranked Predictive Power of Cross-Features (x2y)
year_month

Convert Date into Year-Month (YYYY-MM)