Vector to vector
Write a function that takes a DNA sequence and returns its reverse-complement.
Use it to show that the GC skew of the reverse-complement strand has the same absolute value as the original strand, but opposite sign.
Vector to value
Make these functions using only for()
, if()
and indices. You cannot use the words min
or
max
. The input is a vector called x
.
Please write the code of the following functions:
smallest_value(x)
. Returns the smallest element inx
.You can test your function with the following code.
<- c(16, 15, 19, 10, 14, 7, 12, 18, 20, 9) x min(x) smallest_value(x)
The two results must be the same.
largest_value(x)
. Returns the largest element inx
.You can test your function with the following code.
<- c(7, 6, 18, 5, 16, 19, 7, 10, 14, 11) x max(x) largest_value(x)
The two results must be the same.
place_of_smallest(x)
. Returns the index of the smallest element inx
.You can test your function with the following code.
<- c(17, 12, 5, 6, 14, 15, 20, 13, 9, 20) x which.min(x) place_of_smallest(x)
The two results must be the same.
place_of_largest(x)
. Returns the index of the largest element inx
.You can test your function with the following code.
<- c(11, 14, 7, 6, 13, 10, 18, 16, 14, 14) x which.max(x) place_of_largest(x)
The two results must be the same.