Introducing R and RStudio IDE

Last updated on 2024-07-02 | - + Edit this page

- - - + + +
@@ -401,8 +401,8 @@

Objectives

-

Getting ready to use R for the first time -

+

Getting ready to use R for the first time +


In this lesson we will take you through the very first things you need to get R working.

@@ -423,16 +423,16 @@

Tip: This lesson works best on the cloud

A Brief History of R -

+

A Brief History of R +


The programming language R has been around since 1995, and was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand. R is based off the S programming language developed at Bell Labs and was developed to teach intro statistics. See this slide deck by Ross Ihaka for more info on the subject.

-

Advantages of using R -

+

Advantages of using R +


At more than 20 years old, R is fairly mature and growing in popularity. However, programming isn’t a popularity contest. Here are key advantages of analyzing data in R:

@@ -471,8 +471,8 @@

Discussion: Your experience -

Introducing RStudio Server -

+

Introducing RStudio Server +


In these lessons, we will be making use of a software called RStudio, an Integrated Development Environment (IDE). RStudio, like most IDEs, provides a graphical interface to R, making it more user-friendly, and providing @@ -482,8 +482,8 @@

Discussion: Your experience, a version of RStudio that can be accessed in your web browser. RStudio Server has the same features of the Desktop version of RStudio you could download as standalone software.

-

Log on to RStudio Server -

+

Log on to RStudio Server +


Open a web browser and enter the URL you used to log in at the terminal (provided by your instructors), followed by :8787. For example, if your URL was ec2.12.2.45.678.compute-1.amazonaws.com, @@ -508,8 +508,8 @@

Tip: Make sure there are no spaces before or after you credentials for the genomics Data Carpentry instances will be provided by your instructors.

You should now see the RStudio interface:

-
rstudio default session

Create an RStudio project -

+
rstudio default session

Create an RStudio project +


One of the first benefits we will take advantage of in RStudio is something called an RStudio Project. An RStudio project allows you to more easily:

@@ -568,8 +568,8 @@

Tip: Make your project more reproducible with renv -

Creating your first R script -

+

Creating your first R script +


Now that we are ready to start exploring R, we will want to keep a record of the commands we are using. To do this we can create an R script:

@@ -595,8 +595,8 @@

Tip: Save your script now -

Overview and customization of the RStudio layout -

+

Overview and customization of the RStudio layout +


Here are the major windows (or panes) of the RStudio environment:

rstudio default session

Getting to work with R: navigating directories +


Now that we have covered the more aesthetic aspects of RStudio, we can get to work using some commands. We will write, execute, and save the commands we learn in our genomics_r_basics.R script @@ -721,7 +721,7 @@

Exercise: Work interactively in R

Using functions in R, without needing to master them -

+

Using functions in R, without needing to master them +


A function in R (or any computing language) is a short program that takes some input and returns some output. Functions may seem like an advanced topic (and they are), but you have already used at least one @@ -815,7 +815,7 @@

Exercise: What do these functions do?