Learning R — Part 1

Hanoor Sharma
Analytics Vidhya
Published in
2 min readFeb 7, 2021

In this post I will be covering the following topics that will help us to take first step in learning R language.

  1. Background
  2. Installation
  3. Installing Packages and loading a Library

Background

R was developed by statisticians and data analysts as an interactive environment for data analysis.

Installation

We will need R and R studio on our local computer and I recommend RStudio, an integrated development environment (IDE), to edit and test our code.

Both R and RStudio can be freely downloaded and installed.

Installing R

You can download R from the Comprehensive R Archive Network (CRAN) or search for CRAN on your browser.

  1. Once on the CRAN page, select the version for your operating system — Linux, Mac OS X, or Windows.
  2. Once at the CRAN download page, you will have several choices. You want to install the basesubdirectory. This installs the basic packages you need to get started.
  3. Click on the link for the latest version to start the download.

Installing RStudio

  1. You can start by searching for RStudio on your browser and click Download on website.
  2. Choose the RStudio Desktop free version.
  3. Once you select this option, it will take you to a page in which the operating system options are provided. Click the link showing your operating system.
  4. Click on the downloaded file to start the installation process.

Installing Packages and loading a Library

  1. install.packages — To download and install packages from CRAN-like repositories or from local files. Innstall packages from R console using install.packages("pkg_name") or from RStudio interface: Tools > Install Packages (allows autocomplete)
# To install a single package named dslabs
install.packages("dslabs")
# To install two packages at the same time
install.packages(c("tidyverse", "dslabs")
# To see the list of all installed packages
installed.packages()

(dslabs stands for Data Science Labs. It contains datasets and functions that can be used for data analysis practice, homework and projects in data science courses and workshops. 26 datasets are available for case studies in data visualization, statistical inference, modeling, linear regression, data wrangling and machine learning.)

List of other packages can be found here (https://cran.r-project.org/web/packages/available_packages_by_name.html)

2. library — Loading the package into the R session

library(dslabs)

Where to go from here?

To continue learning R language visit (Learning R — Part 2) which is second post in this series.

--

--