R, RStudio & GitHub

Dr. Ajay Kumar Koli \(\cdot\) 2nd SARA Bootcamp

R Language

Download R Programming Language




“R is a free software environment for statistical computing and graphics.”

Data Science Project Flowchart


Practice in R Console

  1. Addition

  2. Subtraction

  3. Sequence

Structure of R Function

Practice R Console

  1. Combine elements

  2. Create an object

RStudio IDE




“The RStudio integrated development environment (IDE) is a set of tools built to help you be more productive with R and Python.”

Practice in RStudio

  1. An overview of RStudio IDE.

  2. Create project in RStudio.

R
Packages

R Packages

Package is “a collection of functions, data and documentation that extends the capabilties of base R.”


Install R Packages

  • Using Console
# function to install R package
install.packages("tidyverse")

library(tidyverse) #fun to call r package
  • Using RStudio Windows

GitHub

GitHub

“platform that allows developers to create, store, manage, and share their code.”


“It uses Git to provide distributed version control”

Install Git

Install Git

Open Terminal git --version

GitHub Users



GitHub Sign up

  • Username advice
    • all small cases
    • use hyphen - to separate the words
    • the shorter the better
    • make it timeless (do not ajay-jnu, ajay-ny, ajay-microsoft)
    • avoid special characters
    • reuse from your social media
    • comfortable to reveal to the world

GitHub Settings

Enable Two Factor Authentication

Enable Two Factor Authentication

RStudio \(\rightarrow\) Tools \(\rightarrow\) Global Options \(\rightarrow\) Git/SVN

In RStudio save GitHub Details

  • Using Console, Install R package usethis
## install if needed (do this exactly once):
## install.packages("usethis")

library(usethis)
use_git_config(user.name = "ajay-kolii",
               user.email = "mynameajay@gmail.com")

See/Edit saved GitHub information

  • Run in console edit_git_config() from usethis package. OR

  • Run in Terminal
    git config --global --list

GitHub’s Personal Access Token (PAT)


It is a way to authenticate and interact with GitHub’s API and repositories without using your username and password.

Create GitHub’s PAT in Console

library(gitcreds)
create_github_token()


Personal Access Token (PAT)

Personal Access Token (PAT)

Add PAT

gitcreds_set()


View GitHub Credentials

gitcreds_get()


  • To See Saved Credentials, Run in Terminal
    git config --global --list

First .qmd File

  1. Create the file

  2. Save the file

  3. Render the file

🤯 Your Turn


Write a brief note describing your experience of using R and RStudio for the first time.