Please download the answer file 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). 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.

# 1 Using R

## 1.1 Write R commands to make a vector with 40 odd numbers starting from 3

# write your answer here
 [1]  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47
[24] 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81

## 1.2 Write R commands to make a vector with 50 copies of the number 1

# write your answer here
 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[36] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

## 1.3 Write R commands to produce this vector

# write your answer here
[1] "a" "b" "b" "c" "c" "c"

## 1.4 Write R commands to produce this vector

# write your answer here
[1] red   white black blue  brown
Levels: black blue brown red white

## 1.5 Write the R commands to test which elements of state.area are greater than 1E5

# write your answer here
 [1] FALSE  TRUE  TRUE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
[12] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[23] FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE
[34] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
[45] FALSE FALSE FALSE FALSE FALSE FALSE

# 2 Using indices

## 2.1 Show the first 5 elements of the vector state.abb

# write your answer here
[1] "AL" "AK" "AZ" "AR" "CA"

## 2.2 Show all the elements of the vector state.abb, except the first 30

# write your answer here
 [1] "NM" "NY" "NC" "ND" "OH" "OK" "OR" "PA" "RI" "SC" "SD" "TN" "TX" "UT"
[15] "VT" "VA" "WA" "WV" "WI" "WY"

## 2.3 Show the elements of the vector state.name corresponding to states whose area is greater than 1e5

# write your answer here
[1] "Alaska"     "Arizona"    "California" "Colorado"   "Montana"
[6] "Nevada"     "New Mexico" "Texas"     

## 2.4 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

# write your answer here
  one   two three  four
1     2     3     4 

## 2.5 Using the name as index, show the value of two in the vextor x

# write your answer here
two
2