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

7,541

Version

5.0.6

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Bernardo Lares

Last Published

February 9th, 2022

Functions in lares (5.0.6)

ROC

AUC and ROC Curves Data
cache_write

Cache Save and Load (Write and Read)
check_attr

Attribute checker
bring_api

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

Balance Binary Data by Resampling: Under-Over Sampling
check_opts

Validate options within vector
autoline

New Line Feed for Long Strings (Wrapper)
bindfiles

Bind Files into Dataframe
categ_reducer

Reduce categorical values
ci_lower

Lower/Upper Confidence Intervals
cleanText

Clean text
corr_cross

Ranked cross-correlation across all variables
conf_mat

Confussion Matrix
corr

Correlation table
clusterOptimalK

Visualize K-Means Clusters for Several K Methods
clusterVisualK

Visualize K-Means Clusters for Several K
dalex_residuals

DALEX Residuals
cleanNames

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

DALEX Local
ci_var

Confidence Intervals on Dataframe
date_cuts

Convert Date into Year + Cut
corr_var

Correlation between variable and dataframe
dalex_variable

DALEX Partial Dependency Plots (PDP)
cran_logs

Download and plot daily downloads of CRAN packages
clusterKmeans

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

Weighted Cross Tabulation
export_plot

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

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

Daily Portfolio Dataframe
daily_stocks

Daily Stocks Dataframe
fb_process

Process Facebook's API Objects
fb_rf

Facebook Reach and Frequency API
etf_sector

ETF's Sectors Breakdown
files_functions

List all functions used in R script files by package
fb_posts

Facebook Page Posts API
errors

Calculate Continuous Values Errors
fb_post

Facebook Post Comments API
filesGD

Google Drive Files (API v4)
fb_token

Facebook's Long Life User Token
dft

Titanic Dataset
dfr

Results for AutoML Predictions
export_results

Export h2o_automl's Results
db_download

Download/Import Dropbox File by File's Name
db_upload

Upload Local Files to Dropbox
font_exists

Check if Font is Installed
df_str

Dataset columns and rows structure
fb_ads

Facebook Ads API
fb_accounts

Facebook Ad Accounts
h2o_predict_MOJO

H2O Predict using MOJO file
distr

Compare Variables with their Distributions
dist2d

Distance from specific point to line
fb_creatives

Facebook Creatives API
file_name

Extract file raw name and type from file names
formatText

Format a string text as markdown/HTML
get_currency

Download Historical Currency Exchange Rate
formatNum

Nicely Format Numerical Values
get_tweets

Get Tweets
freqs

Frequencies Calculations and Plot
gg_fill_customs

Custom fill, colour and text colours for ggplot2
freqs_list

Frequencies on Lists and UpSet Plot
fb_insights

Facebook Insights API
freqs_plot

Combinated Frequencies Plot for Categorical Features
grepm

Pattern Matching for Any or All Multiple Matches
get_credentials

Load Credentials from a YML File
gain_lift

Cumulative Gain, Lift and Response
freqs_df

Plot for All Frequencies on Dataframe
h2o_predict_model

H2O Predict using H2O Model Object
h2o_selectmodel

Select Model from h2o_automl's Leaderboard
get_mp3

Download MP3 from URL
h2o_shap

SHAP values for H2O Models
forecast_arima

ARIMA Forecast
h2o_results

Automated H2O's AutoML Results
h2o_explainer

DALEX Explainer for H2O
image_metadata

Get Meta Data from Image Files
haveInternet

Internet Connection Check
impute

Impute Missing Values (using MICE)
h2o_automl

Automated H2O's AutoML
holidays

Holidays in your Country
plot_chord

Chords Plot
plot_palette

Plot Palette Colours
plot_cats

Plot All Categorical Features (Frequencies)
importxlsx

Import Excel File with All Its Tabs
install_recommended

Install/Update Additional Recommended Libraries
h2o_predict_binary

H2O Predict using Binary file
grepl_letters

Pattern Matching for Letters considering Blanks
glued

Interpolate a string [glue wrapper]
plot_survey

Visualize Survey Results
mailSend

Send Emails with Attachments (POST)
ip_data

Scrap data based on IP address
lares-exports

Pipe operator
lares_pal

Personal Colours Palette
h2o_predict_API

H2O Predict using API Service
lares

Analytics, Data Mining & Machine Learning Sidekick
remove_stopwords

Remove stop-words and patterns from character vector
removenacols

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

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

Left or Right N characters of a string
iter_seeds

Iterate Seeds on AutoML
li_auth

OAuth Linkedin
listfiles

List files in a directory
is_url

Check if input is_* or are_*
mplot_density

Density plot for discrete and continuous values
li_profile

Get My Personal LinkedIn Data
list_cats

List categorical values for data.frame
shap_var

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

MPLOTS Score Full Report Plots
myip

What's my IP?
plot_timeline

Plot timeline as Gantt Plot
msplit

Split a dataframe for training and testing sets
lasso_vars

Most Relevant Features Using Lasso Regression
model_metrics

Model Metrics and Performance
loglossBinary

Logarithmic Loss Function for Binary Models
splot_summary

Portfolio Plots: Total Summary
splot_roi

Portfolio Plots: Daily ROI
sudoku_solver

Solve Sudoku Puzzles
slackSend

Send Slack Message (Webhook)
move_files

Move files from A to B
writeGS

Google Sheets Writing (API v4)
x2y

Ranked Predictive Power of Cross-Features (x2y)
target_set

Set Target Value in Target Variable
mplot_cuts

Cuts by quantiles for score plot
missingness

Calculate and Visualize Missingness
mplot_cuts_error

Cuts by quantiles on absolute and percentual errors plot
scale_x_comma

Axis scales format
prophesize

Facebook's Prophet Forecast
scrabble_dictionary

Scrabble: Dictionaries
ohse

One Hot Smart Encoding (Dummy Variables)
mplot_response

Cumulative Response Plot
mplot_roc

ROC Curve Plot
outlier_turkey

Outliers: Tukey<U+2019>s fences
read.file

Read Files Quickly (Auto-detected)
mplot_gain

Cumulative Gain Plot
model_preprocess

Automate Data Preprocess for Modeling
splot_types

Portfolio Plots: Types of Stocks
trendsTime

Google Trends: Timelines Plot
spread_list

Spread list column into new columns
readGS

Google Sheets Reading (API v4)
sentimentBreakdown

Sentiment Breakdown on Text
stocks_file

Get Personal Portfolio's Data
statusbar

Progressive Status Bar (Loading)
scrabble_words

Scrabble: Highest score words finder
textTokenizer

Tokenize Vectors into Words
mplot_importance

Variables Importances Plot
mplot_splits

Split and compare quantiles plot
mplot_topcats

Top Hit Ratios for Multi-Classification Models
trim_mp3

Trim MP3 Audio File
theme_lares

Theme for ggplot2 (lares)
mplot_lineal

Linear Regression Results Plot
plot_df

Plot Summary of Numerical and Categorical Features
numericalonly

Select only numerical columns in a dataframe
mplot_conf

Confussion Matrix Plot
ohe_commas

One Hot Encoding for a Vector with Comma Separated Values
mplot_metrics

Model Metrics and Performance Plots
replacefactor

Replace Factor Values
plot_nums

Plot All Numerical Features (Boxplots)
ngrams

Build N-grams and keep most frequent
noPlot

Plot Result with Nothing to Plot
rtistry_sphere

Generative Art: Sphere XmodY
topics_rake

Keyword/Topic identification using RAKE
scrabble_score

Scrabble: Word Scores
scrabble_points

Scrabble: Tiles Points
tic

Stopwatch to measure timings in R
tree_var

Recursive Partitioning and Regression Trees
trendsRelated

Google Trends: Related Plot
outlier_zscore_plot

Outliers: Z-score method plot
queryGA

Queries on Google Analytics
outlier_zscore

Outliers: Z-score method
quiet

Quiet prints and verbose noice
normalize

Normalize Vector
num_abbr

Abbreviate numbers
queryDB

PostgreSQL Queries on Database (Read)
quants

Calculate cuts by quantiles
reduce_pca

Reduce Dimensionality with PCA
reduce_tsne

Reduce Dimensionality with t-SNE
stocks_obj

Portfolio's Calculations and Plots
textFeats

Create features out of text
textCloud

Wordcloud Plot
stocks_hist

Download Stocks Historical Data
vector2text

Convert a vector into a comma separated text
winsorize

Outliers: Winsorize
splot_change

Portfolio Plots: Daily Change
replaceall

Replace Values With
removenarows

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

Portfolio Plots: Dividends per Year and Quarter
splot_growth

Portfolio Plots: Growth (Cash + Invested)
stocks_quote

Download Stocks Current Data
splot_etf

Portfolio's Sector Distribution (ETFs)
stocks_report

Portfolio's Full Report and Email
try_require

Check if Specific Package is Installed
updateLares

Update the library (dev or CRAN version)
year_month

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

Zero Variance Columns