DEV Community

Cover image for Introduction to R Studio
Julius170
Julius170

Posted on

Introduction to R Studio

Introduction to R Studio

R is a programming language used for Statistical computations, it makes use of an Interactive Integrated Development Environment IDE
which includes an editor, R specific features and a console for executing your code
A newly installed version of R is called Base R because it is automatically installed with few essential packages after downloading the base subdirectory.
Alt Text

While

R Studio is an Interactive User Environment that uses the R programming language to develop the statistical programs , It is neither a programming language or software for developers but simply an Interactive Desktop Environment for Data Analysis. It is an indispensable feature in Data Science because of its ability to quickly explore data as a necessity of success.
It cannot be used without R.
Here are some of its importance:

  • It is free and open-source( it is freely available for end users)
  • It is platform-independent ( it can conveniently run on Mac and Windows etc.)

How To Download and Install R Studio

Step 1: Search for R Studio on Google ( or any other browser)

Alt Text

Step 2: Click on R Studio From CRAN Repository( The Comprehensive R Archive Network is an R Studio Repository for downloading the R Studio )

Alt Text

Step 3: Click on The Free Desktop Version ( It's safe and affordable, amongst all the other options the free desktop version is a very good download version)

Alt Text

Step 4: Find your OS Download Link. (It'll take you to a page where the operating system downloads are available. Find the OS suitable for the device your using)

Alt Text

Step 5: Install R Studio. After downloading the installation file, click on the downloaded file to start the installation process.Alt Text

First time on R Studio

  • On Window Click the start icon and Search R Studio
  • On Mac, you can find it in the app folder without the mouse to you can click on Commands + Space, click enter -*and start the *R Studio
    Alt Text

  • To start a new script to u can click on File > New file > R script at the top left corner of the left pane

  • A new pane on the top left will be opened where you can start writing your scripts

    Key Bindings for running a script or a line of code

    These are keyboard versions of performing tasks that you might want to use concurrently which might be considered strenuous

  • To run a script on R console using a Mac you can use Command+Shift+Return
    using windows you can use Control+Shift+Enter

  • To run a single line of code on the console using a Mac you can use Command+Return, on Windows you can use (Control+Enter)

  • You can check the latest R Studio Cheatsheet
    OR

    • Click on tools at the top left of the left pane
    • Click on Cheatsheets Alt Text
    • Click on R Studio IDE Cheat sheet

Alt Text

Getting started with R Studio

Installing and loading packages on R Studio

There are two ways of installing R Studio

  1. Using the R Studio to download the package directly from the CRAN Repository
    • Click on tools Alt Text
    • Click on Install packages Alt Text
    • On the second bar, you can fill in the name of the package to Install, here are a few R Studio packages you can install.
    • When installing a package through the R Studio an advantage to filling the bar is autocomplete, so you can choose from the droplist even when you forget the name of the package (Ensure you are connected to the internet when installing a package)
    • Afterward, you can load the package with the following code library(tidyverse)
  2. Or you can decide to install the package manually with the following lines of code
    • Write the code format install.packages("tidyverse") to install the package Alt Text
  • To load the packages use the following code library("tidyverse")

  • You can also install more that one package by putting in a character function using the following code format
    Alt Text

install.packages(c("tidyverse","dslabs"))

  • After running a lot of packages and you want to check the list of packages already installed you can pass in the code format Alt Text

installed.packages() to check the list of packages already installed

Note: it is always considered cautious to write down a script of all the basic packages to be installed in a case where the R Studio is to be reset.

  • Unlike most inbuilt functions in R, there are few which do not always take in an argument eg ls() and a few others An example is after assigning values to a variable Alt Text

the ls() function displays a list of the already inputted assignments
Alt Text

  • Also if you can't remember the arguments to pass in a function or you want to use a function for the first time you can make use of help with the following format to bring a list of all possible arguments you can pass into the function. An example is Alt Text

OR
Alt Text

and here are the possible arguments
Alt Text

  • You can use the following format to print an assignment either by writing the variable name only or passing it as an argument to the "print" function Alt Text

Note: To write a comment on R is done by simply beginning a text with a "#" sign and any code coming after the sign will not run.

Latest comments (1)

Collapse
 
zeroth_bravo profile image
Adeola Idowu

This is really detailed

Nice 👍