# Let's first create a numeric and a character vector. # There is no need to do this again if you already did it in the previous exercise! > odd_n <- c(1, 3, 5, 7, 9) # Extract the second element of the numeric vector. > odd_n[2] [1] 3 # Extract the second and fourth elements of the numeric vector. > odd_n[c(2, 4)] [1] 3 7 # Extract all but the two first elements of the numeric vector. > odd_n[c(-1, -2)] [1] 5 7 9 # If you select a position that is not in the numeric vector > odd_n[c(1,6)] [1] 1 NA # There is no sixth value in this vector so R returns a null value (i.e. NA) # NA stands for 'Not available'. # You can use logical statement to select values. > odd_n[odd_n > 4] [1] 5 7 9 # Extract all elements of the character vector corresponding exactly to "blue". > char_vecteur[char_vecteur == "blue"] [1] "bleu" # Note the use of the double equal sign ==.