Getting Started with R & R Studio

Jennifer Shin
3 min readJul 19, 2022

R is am opem sourxce statistical poetram that is used by statisticians and reaearchers to build, run, and test statistical model. Another open source application, called R Studio, is a popular add on to the R software that is typically installed on top of the base R software. R Studio allows users access the base R software through a more user friendly graphical user interface as well a number of helpful features.

If this is your first time using R or R Studio, you will need to install the base R and R Studio software on your computer (or sign up for R Studio cloud if you want access to R via the internet).

To install R and R Studio on your computer, download and run the approrpiate installation file based on your operating system. once you have installed the necessary software

packages in Step 1 and then use these packages to write code to import your data in Step 2.

STEP 1: Download and install the software.

1 .Download and install R: https://cran.r-project.org/Download

2. Download and install R Studio: https://rstudio.com/products/rstudio/#rstudio-desktop

3. Open R Studio.

STEP 2: install packages

Click on the Packages tab in the bottom-right section and then click on install.
In the Install Packages dialog, write the package name you want to install under the Packages field and then click install. This will install the package you searched for or give you a list of matching packages based on your package text.

We can also install packages using code. Specifically, by opening R Studio and running the following code in the command panel ( in the lower left corner of R Studio): install.packages(“readr”)

STEP 3: Configure the Software

Working Directory: R is pointed to a specific directory called current working directory in which your R files are saved or if you want to read a file then it should be present in that working directory. Dealing with working directory is part and parcel of R programming.

STEP 4: Import Data

R Studio allows users more than one way to use certain functionalities. Loading your first dataset can be done by

The most useful functions for this course are read_csv() and read_tsv() read_csv()

reads comma delimited files, read_csv2() reads semicolon separated files (common in countries where , is used as the decimal place)
read_tsv() reads tab delimited files, and read_delim() reads in files with any delimiter.

(1) accessing the option via through the user interface by going to File → Import Dataset → From Text and selecting the appropriate file.

(2) loading the readr package and using the read.csv(“<file name>”).
For example, if your file is cars.csv, the following code can be used to import a csv file.

library(readr)
cars <- read.csv("cars.csv")

Note: cars.csv must be saved in your working directory in R Studio (otherwise the application will be unable to locate). If you do not know your current working directory, run the following in R Studio: setwd(“<full path to the working directory on your computer>”)

Alternatively:
(1) cars.csv can be replaced with the full path (including file name) where the file has been saved on your computer or
(2) the working directory can be changed in R Studio.

--

--