For all homework assignments please provide the code, the R output and your thoughtful explanation of the code.
strings <- c("s", "o", "c", "i", "a", "l", "s", "c", "i", "e", "n", "c", "e")
strings[1:6]
gives us the first 6 characters, spelling the words "social". Find two different ways to reverse the word string of strings[1:6]
, one
with and one without a function. Explain in words how each of these solutions work. Hint:
remember help.search()
. If you get stuck always explain what you did and how you
got stuck. strings[-1]
do?. Explain in words what this does? Provide two
different solutions, one using only negative numbers and one using only positive numbers to
extract the character vectors "s" "c" "i" "e" "n" "c" "e"
. strings
that creates the word "coins" c("c","o", "i", "n",
"s"). Explain your code.set.seed(123) x <- matrix(rnorm(40), 5)
diag()
could help) that is 3 by 3. Then create two matrices composed entirely of the number 24, one which is 3 by 3 and the other which is 8 by 3. Try to matrix multiply (remember what matrix multiplication is!) your identity matrix by both matrices. Report the results and explain what happens. Then transpose the 3 by 8 matrix and try to matrix multiply it again. Give the result and explain in words how you got there.