---
author: "Prepared by Andrés Aravena, Ph.D."
number: STUDENT_NUMBER
title: "Class 7: Quiz 1"
subtitle: "Computing in Molecular Biology 1 --- Molecular Biology and Genetics Department"
description: "First rehearsal for Midterm Exam"
date: "October 8, 2018"
output: 
  html_document: 
    number_sections: yes
    self_contained: no
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(comment=NA, echo = TRUE)
```
:::::{style="border: solid thin; padding:3pt"}
Please download the [answer file](https://anaraven.bitbucket.io/`r Sys.getenv("FULL")`answers.Rmd) and edit it on *Rstudio*. Write your student number in the correct place at the beginning of the answer file. You should be able to **Knit HTML** and get the same results as the document you have in paper. Please do **Knit** often and verify that your document has no errors. **If your document does not *Knit*, you will not have full grade.**

When you finish, send the `answers.Rmd` file to my mailbox ([`andres.aravena+cmb@istanbul.edu.tr`](mailto:andres.aravena+cmb@istanbul.edu.tr)). Be sure to use the correct email address and send only one file. If you send the wrong file your grade will be 0. **Please wait until you receive a confirmation email before closing your computer.**

You can use **only** your *personal handwritten* notes and the help window of RStudio. All questions are independent and can be answered in any order. Some question can be answered in more than one way. Only one correct answer is required.

**IMPORTANT:** Write your student number in the correct place at the beginning of the answer file.
:::::

# Using R
## Write R commands to make a vector with 40 odd numbers starting from 3
```{r q1a}
seq(from=3, by=2, length=40)
```

## Write R commands to make a vector with 50 copies of the number 1
```{r q1b}
rep(1, 50)
```

## Write R commands to produce this vector
```{r q1c}
rep(c("a", "b", "c"),1:3)
```

## Write R commands to produce this vector
```{r q1d}
factor(c("red", "white", "black", "blue", "brown" ))
```

## Write the R commands to test which elements of `state.area` are greater than 1E5
```{r q1e}
state.area>1e5
```


# Using indices
## Show the first 5 elements of the vector `state.abb`
```{r q2a}
state.abb[1:5]
```

## Show all the elements of the vector `state.abb`, except the first 30
```{r q2b}
state.abb[-(1:30)]
```

## Show the elements of the vector `state.name` corresponding to states whose area is greater than 1e5
```{r q2c}
state.name[state.area>1e5]
```

## Create a vector with the values 1, 2, 3, and 4, and with names "one", "two", "three", and "four".
Assign this vector to the variable `x`. Then show the content of `x`
```{r q2d}
x <- c(one=1, two=2, three=3, four=4)
x
```

## Using the name as index, show the value of `two` in the vextor `x`
```{r q2e}
x["two"]
```

# About Computing
Please answer the following questions:

## What is a *computer*? what are computers useful for?

> A computer is a general purpose machine which can be used to handle and process data and information

## What are the parts of a computer?

> Memory (primary and secondary, also known as RAM and Disk), processor, input/output (also known as interface)

## How do computers represent information?

> with numbers

## What is a *prompt*? What is the interpretation?

> Prompt is a sign showing that the computer is ready to receive commands. In R the prompt is `>`

## Can you use *Microsoft Word* for scientific computing?

> NO, NEVER, NEVER, NEVER. UNDER NO CIRCUMSTANCE.

## What are the advantages of *Markdown* as a way to represent documents?

> Files in Markdown format are text files, therefore can be read with any system today and in the future. Can be read by humans and computers. Markdown files allows to write documents with structure that is independent of style.

# About R
Please answer the following questions:

## Which are the basic *data types in R*?

> Numeric, Character, Logic and Factor

## What is the meaning of `NA`? Why it is useful?

> `NA` represent missing data. It is important to show that the value exists but it is unknown.

## What types of data can be used as indices of vectors in R? What are the advantages of each one?

> Numeric positive: values to keep. Numeric negative: values to skip. Logic: keep only `TRUE`. Character: easier to understand.

<style type="text/css">
h1 {font-size: 24px;}
h2 {font-size: 15px; font-weight: normal; margin-bottom: 0; line-height: 20px;}
hr {page-break-before: always; border: 0;} 
blockquote { border: #eee solid;}
.header-section-number::after {content: ". ";}
</style>
