Image contains R, Python, and DB logo

Setting up R, Python, and SQL in RStudio

The main aim of this blog to show, how you can configure R, Python, and SQL in a single R-markdown file. Most of time we have to use data from databases and python code along with R functions, and having a setup that bring goodness of all the tool in one place comes really handy. Setup Python in Rstudio To set up R Python And SQL in the Rstudio you have to first install miniconda....

July 4, 2022 Â· 5 min Â· Dr. Ankit Deshmukh

Random Forest with R-Programming

The following packages are required for the random forest if(!require(tidyverse)){install.packages("tidyverse");library(tidyverse)} if(!require(janitor)){install.packages("janitor");library(janitor)} # for rename if(!require(randomForest)){install.packages("randomForest");library(randomForest)} if(!require(caret)){install.packages("caret");library(caret)} # for `confustionMatrix` A Random forest is made of Random Trees Data <- read_csv(file = here::here("content/post/2022-06-26-random-forest", "german_credit.csv")) Exploring the dataset Data <- clean_names(Data) Data$creditability <- as.factor(Data$creditability) glimpse(Data) ## Rows: 1,000 ## Columns: 21 ## $ creditability <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … ## $ account_balance <dbl> 1, 1, 2, 1, 1, 1, 1, 1, 4, 2, 1, 1, … ## $ duration_of_credit_month <dbl> 18, 9, 12, 12, 12, 10, 8, 6, 18, 24,… ## $ payment_status_of_previous_credit <dbl> 4, 4, 2, 4, 4, 4, 4, 4, 4, 2, 4, 4, … ## $ purpose <dbl> 2, 0, 9, 0, 0, 0, 0, 0, 3, 3, 0, 1, … ## $ credit_amount <dbl> 1049, 2799, 841, 2122, 2171, 2241, 3… ## $ value_savings_stocks <dbl> 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 2, … ## $ length_of_current_employment <dbl> 2, 3, 4, 3, 3, 2, 4, 2, 1, 1, 3, 4, … ## $ instalment_per_cent <dbl> 4, 2, 2, 3, 4, 1, 1, 2, 4, 1, 2, 1, … ## $ sex_marital_status <dbl> 2, 3, 2, 3, 3, 3, 3, 3, 2, 2, 3, 4, … ## $ guarantors <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … ## $ duration_in_current_address <dbl> 4, 2, 4, 2, 4, 3, 4, 4, 4, 4, 2, 4, … ## $ most_valuable_available_asset <dbl> 2, 1, 1, 1, 2, 1, 1, 1, 3, 4, 1, 3, … ## $ age_years <dbl> 21, 36, 23, 39, 38, 48, 39, 40, 65, … ## $ concurrent_credits <dbl> 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, … ## $ type_of_apartment <dbl> 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, … ## $ no_of_credits_at_this_bank <dbl> 1, 2, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, … ## $ occupation <dbl> 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 3, 3, … ## $ no_of_dependents <dbl> 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, … ## $ telephone <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … ## $ foreign_worker <dbl> 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, … Assess the creditabiliy with the help of other variables # code ------------------------------------------------------------------------- ggplot(data = Data, aes(x = age_years, color = creditability, fill = creditability)) + geom_histogram(binwidth = 5, position = "identity", alpha = 0....

June 26, 2022 Â· 6 min Â· Dr. Ankit Deshmukh

How to create a pretty facet-boxplot with custom fonts

How to make a better boxplot with custom fonts, let’s explore this in this post, it can be used for the standard template for boxplot with facet and user defined fonts. Required R libraries: if(!require(tidyverse)){install.packages("tidyverse");library(tidyverse)} # for ggplot2 function if(!require(gapminder)){install.packages("gapminder");library(gapminder)} # for sample data if(!require(showtext)){install.packages("showtext");library(showtext)} # to import fonts Add fonts in R session font_add_google("Karla", "Karla") # adding local font font_add(family = "Helvetica", regular = "C:/Windows/Fonts/Helvetica 400.ttf") # Adding from Google fonts font_add_google("Roboto Slab", "Roboto Slab") # adding font from the web/google font font_families() ## [1] "sans" "serif" "mono" "wqy-microhei" "Karla" ## [6] "Helvetica" "Roboto Slab" Define theme for Boxplot and fonts themeBox <- function(base_family = "sans", exFont, ....

January 21, 2022 Â· 2 min Â· Dr. Ankit Deshmukh

Hello R Markdown!

R Markdown This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com. A few useful syntax are shown below in the post: 1. You can embed an R code chunk like this: summary(cars) ## speed dist ## Min. : 4.0 Min. : 2.00 ## 1st Qu.:12.0 1st Qu.: 26.00 ## Median :15....

December 1, 2021 Â· 3 min Â· Dr Ankit Deshmukh
Image of R and Quote

Getting Started with R Programming

R is a very versatile statistical tool and programming language. It’s my all-time good-to-go data analysis tool. It is fast, reliable and nifty. It provides great flexibility for my daily work and analysis tasks. If one uses R, they could consider RStudio as a more sophisticated GUI than the Base R once. 1. Installing R Step 01: Install R-Binaries from R-Project Step 02: Install RStudio IDE from RStudio 2. Customizing RStudio A lot of ways you can make RStudio more useful for your personal use....

September 20, 2021 Â· 3 min Â· Dr. Ankit Deshmukh