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

# 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 running the above code. Download it here.

CRAN NOTE: I do NOT have plans to submit the library to CRAN, eventhough I'm a huge fan and it passes all its quality tests. I see lares more of an everyday useful and shareble package rather than a "specialized for a specific task" library. It has too many various kinds of functions, from NLP to querying APIs, plotting Machine Learning results to market stocks and portfolio reports. I gladly share my code with ouR community and encourage you to use/comment/share it, but I do think that CRAN is not aiming for this kind of libraries in their repertoire.

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 persepective 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.

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 Official 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

7,541

Version

4.10.6

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Bernardo Lares

Last Published

May 31st, 2021

Functions in lares (4.10.6)

check_attr

Attribute checker
categ_reducer

Reduce categorical values
cache_write

Cache Save and Load (Write and Read)
bring_api

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

Visualize K-Means Clusters for Several K Methods
corr

Correlation table
conf_mat

Confussion Matrix
cleanText

Clean text
clusterKmeans

Automated K-Means Clustering + PCA
check_opts

Validate options within vector
corr_cross

Ranked cross-correlation across all variables
ci_lower

Lower/Upper Confidence Intervals
clusterVisualK

Visualize K-Means Clusters for Several K
db_download

Download/Import Dropbox File by File's Name
ROC

AUC and ROC Curves Data
autoline

New Line Feed for Long Strings (Wrapper)
corr_var

Correlation between variable and dataframe
export_results

Export h2o_automl's Results
db_upload

Upload Local Files to Dropbox
fb_accounts

Facebook Ad Accounts
crosstab

Weighted Cross Tabulation
errors

Calculate Continuous Values Errors
distr

Compare Variables with their Distributions
daily_portfolio

Daily Portfolio Dataframe
fb_insights

Facebook Insights API
fb_post

Get Facebook's Post Comments (API Graph)
etf_sector

ETF's Sectors Breakdown
fb_posts

Get Facebook's Page Posts (API Graph)
dalex_residuals

DALEX Residuals
dalex_variable

DALEX Partial Dependency Plots (PDP)
export_plot

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

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

Convert Date into Year + Cut
fb_process

Process Facebook's API Objects
file_name

Get file names without extensions
file_type

Get file extensions without file names
df_str

Dataset columns and rows structure
files_functions

List all functions used in R script files by package
filesGD

Google Drive Files (API v4)
gain_lift

Cumulative Gain, Lift and Response
get_credentials

Load Credentials from a YML File
freqs_df

Plot for All Frequencies on Dataframe
gg_bars

Quick Nice Bar Plot
freqs

Frequencies Calculations and Plot
get_tweets

Get Tweets
dfr

Dataset: Results for AutoML Predictions
fb_creatives

Facebook Creatives API
font_exists

Check if Font is Installed
fb_ads

Facebook Ads API
gg_colour_customs

Custom colours for scale_color_manual [Deprecated]
forecast_arima

ARIMA Forecast
grepm

Pattern Matching for Any or All Multiple Matches
h2o_predict_MOJO

H2O Predict using MOJO file
gg_fill_customs

Custom colours for scale_fill_manual [Deprecated]
glued

Interpolate a string [glue wrapper]
freqs_plot

Combinated Frequencies Plot for Categorical Features
freqs_list

Frequencies on Lists and UpSet Plot
gg_pie

Density plot for discrete and continuous values
h2o_automl

Automated H2O's AutoML
impute

Impute Missing Values (using MICE)
install_recommended

Install/Update Additional Recommended Libraries
grepl_letters

Pattern Matching for Letters considering Blanks
lares_pal

Personal Colours Palette
lasso_vars

Most Relevant Features Using Lasso Regression
list_cats

List categorical values for data.frame
li_profile

Get My Personal LinkedIn Data
haveInternet

Internet Connection Check
listfiles

List files in a directory
holidays

Holidays in your Country
loglossBinary

Logarithmic Loss Function for Binary Models
mplot_conf

Confussion Matrix Plot
mplot_full

MPLOTS Score Full Report Plots
move_files

Move files from A to B
mplot_density

Density plot for discrete and continuous values
mplot_response

Cumulative Response Plot
mplot_roc

ROC Curve Plot
h2o_predict_binary

H2O Predict using Binary file
h2o_shap

SHAP values for H2O Models
h2o_selectmodel

Select Model from h2o_automl's Leaderboard
left

Left or Right N characters of a string
gg_text_customs

Custom colours for scale_color_manual on texts [Deprecated]
h2o_explainer

DALEX Explainer for H2O
ngrams

Build N-grams and keep most frequent
noPlot

Plot Result with Nothing to Plot
h2o_predict_API

H2O Predict using API Service
is_url

Check if input is_* or are_*
ip_data

Scrap data based on IP address
lares-exports

Pipe operator
numericalonly

Select only numerical columns in a dataframe
ohe_commas

One Hot Encoding for a Vector with Comma Separated Values
outlier_turkey

Outliers: Tukey<U+2019>s fences
mplot_metrics

Model Metrics and Performance Plots
mplot_lineal

Linear Regression Results Plot
ohse

One Hot Smart Encoding (Dummy Variables)
prophesize

Facebook's Prophet Forecast
plot_timeline

Plot timeline as Gantt Plot
balance_data

Balance Binary Data by Resampling: Under-Over Sampling
bindfiles

Bind Files into Dataframe
queryGA

Queries on Google Analytics
ci_var

Confidence Intervals on Dataframe
daily_stocks

Daily Stocks Dataframe
cleanNames

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

Remove stop-words and patterns from character vector
mailSend

Send Emails with Attachments (POST)
li_auth

OAuth Linkedin
missingness

Calculate and Visualize Missingness
shap_var

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

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

Send Slack Message (Webhook)
plot_palette

Plot Palette Colours
dft

Dataset: Titanic Sub-dataset por Examples
dist2d

Distance from specific point to line
dalex_local

DALEX Local
fb_rf

Facebook Reach and Frequency API
fb_token

Facebook's Long Life User Token
formatNum

Nicely Format Numerical Values
formatText

Format a string text as markdown/HTML
spread_list

Spread list column into new columns
lares

Analytics, Visualization & Machine Learning Tasks Library
quiet

Quiet prints and verbose noice
outlier_zscore_plot

Outliers: Z-score method plot
outlier_zscore

Outliers: Z-score method
read.file

Read Files Quickly (Auto-detected)
readGS

Google Sheets Reading (API v4)
scrabble_words

Scrabble: Highest score words finder
theme_lares

Theme for ggplot2 (lares)
statusbar

Progressive Status Bar (Loading)
tic

Stopwatch to measure timings in R
model_preprocess

Automate Data Preprocess for Modeling
model_metrics

Model Metrics and Performance
mplot_gain

Cumulative Gain Plot
msplit

Split a dataframe for training and testing sets
mplot_importance

Variables Importances Plot
topics_rake

Keyword/Topic identification using RAKE
tree_var

Recursive Partitioning and Regression Trees
textTokenizer

Tokenize Vectors into Words
stocks_hist

Download Stocks Historical Data
stocks_file

Get Personal Portfolio's Data
trim_mp3

Trim MP3 Audio File
textFeats

Create features out of text
plot_survey

Visualize Survey Results
splot_growth

Portfolio Plots: Growth (Cash + Invested)
sentimentBreakdown

Sentiment Breakdown on Text
myip

What's my IP?
try_require

Check if Specific Package is Installed
plot_df

Plot Summary of Numerical and Categorical Features
scale_x_comma

Axis scales format
plot_nums

Plot All Numerical Features (Boxplots)
scrabble_dictionary

Scrabble: Dictionaries
quants

Calculate cuts by quantiles
splot_roi

Portfolio Plots: Daily ROI
get_currency

Download Historical Currency Exchange Rate
h2o_results

Automated H2O's AutoML Results
get_mp3

Download MP3 from URL
h2o_predict_model

H2O Predict using H2O Model Object
stocks_obj

Portfolio's Calculations and Plots
x2y

Ranked Predictive Power of Cross-Features (x2y)
image_metadata

Get Meta Data from Image Files
updateLares

Update the library
stocks_quote

Download Stocks Current Data
vector2text

Convert a vector into a comma separated text
splot_change

Portfolio Plots: Daily Change
mplot_cuts

Cuts by quantiles for score plot
iter_seeds

Iterate Seeds on AutoML
importxlsx

Import Excel File with All Its Tabs
json2vector

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

Cuts by quantiles on absolute and percentual errors plot
splot_etf

Portfolio's Sector Distribution (ETFs)
normalize

Normalize Vector
mplot_splits

Split and compare quantiles plot
mplot_topcats

Top Hit Ratios for Multi-Classification Models
target_set

Set Target Value in Target Variable
year_week

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

Zero Variance Columns
scrabble_points

Scrabble: Tiles Points
queryDB

PostgreSQL Queries on Database (Read)
scrabble_score

Scrabble: Word Scores
textCloud

Wordcloud Plot
year_month

Convert Date into Year-Month (YYYY-MM)
removenarows

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

Plot All Categorical Features (Frequencies)
replacefactor

Replace Factor Values
plot_chord

Chords Plot
num_abbr

Abbreviate numbers
replaceall

Replace Values With
trendsRelated

Google Trends: Related Plot
trendsTime

Google Trends: Timelines Plot
splot_summary

Portfolio Plots: Total Summary
rtistry_sphere

Generative Art: Sphere XmodY
stocks_report

Portfolio's Full Report and Email
splot_types

Portfolio Plots: Types of Stocks
sudoku_solver

Solve Sudoku Puzzles
winsorize

Outliers: Winsorize
writeGS

Google Sheets Writing (API v4)