--- author: "Write your name here" number: STUDENT_NUMBER title: "Homework 2" subtitle: "Computing in Molecular Biology 1 – Molecular Biology and Genetics Department" description: "First rehearsal for Midterm Exam" date: "November 9, 2020" output: html_document: number_sections: yes self_contained: no --- # Creating vectors ## Write the R command to produce this vector ```{r q1} # write your answer here ``` ## Write the R command to produce a vector with numbers 0, 0.1, 0.2, …, 0.9, 1.0 ```{r q2} # write your answer here ``` ## Create a named 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 q3} # write your answer here ``` ## Using the name as index, show the value of `two` in the vector `x` ```{r q4} # write your answer here ``` # Using indices Your R system has already some vectors to be used for exercises. One of them is `letters`, containing the English alphabet ## Write the command to show the content of `letters` ```{r q5} # write your answer here ``` ## Find the second element ```{r q6} # write your answer here ``` ## Find the 10th element ```{r q7} # write your answer here ``` ## Make a logic vector that is `TRUE` for the vowels in `letters`. In English the vowels are `c("a", "e", "i", "o", "u")` ```{r q8} # write your answer here ``` ## Find the last element ```{r q9} # write your answer here ``` ## Find the first 6 elements ```{r q10} # write your answer here ``` ## Find the last 6 elements ```{r q11} # write your answer here ``` ## Find all except the first 3 elements ```{r q12} # write your answer here ``` ## Find the elements in positions 5, 7, 9, …, 15 ```{r q13} # write your answer here ``` # USA states Other vectors already included in R are used to describe USA states. They include `state.area` and `state.name`, which we will use in this exercise. In the future we will work with other countries' data, but these are easier to use for this homework. ## Write the R command to create a logic vector, which is `TRUE` for the elements of `state.area` that are greater than 5E4 ```{r q14} # write your answer here ``` ## Show the first 4 elements of the vector `state.name` ```{r q15} # write your answer here ``` ## Show all the elements of the vector `state.name`, except the first 40 ```{r q16} # write your answer here ``` ## Show the elements of the vector `state.name` corresponding to states whose area is greater than 2E5 ```{r q17} # write your answer here ```