# Getting to Know R

### Getting ready for the course

1. Download `Intro_to_R.tar` from `https://ki-data.mit.edu/bcc/teaching/Intro_to_R/` onto Desktop.
2. Un-compress `Intro_to_R.tar` to a folder "Intro\_to\_R"
3. Open RStudio
4. Under the File menu, click on New project, choose Existing Directory
5. Use Browse to locate to the "Intro\_to\_R" folder and then Create Project This will be your working directory for the rest of the day (e.g. \~/Desktop/Intro\_to\_R)
6. Create a new R script (File > New File > R script) and save it in your working directory (e.g. intro\_to\_R.R). Here, you can type all the commands we run during the course, and save it for later reference.

Using R as a calculator

```r
> 1+2
[1] 3
> 1+2*3+4*5
[1] 27
```

R is good at statistics

```r
> group1<-c(4.5,4.7,4.2,4.8,3.9)
> group2<-c(6.0,5.9,5.8,5.5,6.2)
> t.test(group1,group2)

        Welch Two Sample t-test

data:  group1 and group2
t = -7.2281, df = 7.1573, p-value = 0.0001556
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.9355112 -0.9844888
sample estimates:
mean of x mean of y 
     4.42      5.88 
```

The R syntax from an example script

```r
# Load libraries
library(Biobase)
library(limma)
library(ggplot2)

# Setup directory variables
baseDir <- getwd()
dataDir <- file.path(baseDir, "data")

# Load data
design_dat <- read.table(file.path(dataDir, 'mouse_exp_design.csv'), header=T, sep=",", row.names=1)

```

```
*The above snippet of R code has many different “parts of speech” for R (syntax):
*the comments # and how they are used to document function and its content
*the assignment operator <-
*variables and functions
*the = for arguments for functions

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://igb.mit.edu/mini-courses/r/intro-to-r/getting-to-know-r.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
