Preliminary

In the header above, place your name as author (remember to keep the quotes) and add today’s date.

The R programming language

R is a programming language and free software environment for statistical computing and graphics. It’s not only a powerful statistical programming language but also the go-to data analysis tool for many computational genomics experts. We will explore how high-dimensional genomics datasets can be analyzed with core R packages and functions.

You can learn more about R at the R Project Homepage.

The Python programming language

Python is a programming language used in many areas of science, data analysis, and artificial intelligence. It is one of the most widely used languages in computational biology because it is readable, flexible, and has strong tools for working with data.

In this course, we will eventually use Python to analyze cancer datasets, make plots, and compare results with the R versions of the activities.

You can learn more about Python at the Python Homepage.

RStudio

RStudio is an Integrated Development Environment (IDE) for creating, viewing, and exploring code, variables, files, plots, and more, all in one application. We are currently working in RStudio.

R Markdown

This is an R Markdown document. We can combine text, code, and output together in an R Markdown file. We’ll talk more about R Markdown next time.

R code chunks are embedded in gray boxes. Run the code by clicking on the green arrow.

plot(cars)     # this code gives us a plot of the data set 'cars' 

The hash symbol in the code chucnks allows us to include comments. These comments will not show up when actually running the code.

Operations

R allows you to do simple operations. You can find the value of these operations by runnging the individual code chunks (clicking the green arrow).

Examples

Add 3 and 4 with R:

3 + 4
## [1] 7

Add 3 and 4 with Python:

3 + 4
## 7

Subtract 2 from 7 with R.

7 - 2
## [1] 5

Subtract 2 from 7 with R.

7 - 2
## 5

Note this difference between R and Python code chunks: In the curly braces at the beginning of the chunk, we have {r} for R and {python} for python. We can seamlessly program in either R or Python in RStudio. We can also have both codes in a single session as we are doing here.

Multiply 4 by 5.

4 * 5
## [1] 20
4 * 5
## 20

Divide 15 by 3.

15 / 3
## [1] 5
15 / 3
## 5.0

Find the value of 2 cubed.

2^3
## [1] 8
2**3
## 8

Note that Python has a different operator for cubing. We will come across situations like this!

Practice

1.) Add 5 and 2.

2.) Multiply 6 and 4.

3.) Find the value of 4 squared.

4.) Divide 36 by 6.

5.) Subtract 4 from 17.

Great work! Let’s make a copy of what you did. Click on the “Knit” button in the function ribbon at the top of this windown, and “Knit to HTML.”