Question: Write a function called back ( ) that inputs a vector x and a number n and outputs the last n elements of x .

Write a function called back() that inputs a vector x and a number n and outputs the last n elements of x. When n is greater than length(x), your function should just output x.
With n =6, verify that your back() function works on the vectors numeric(0), seq(1,99, by =2), and c("waffles", "friends", "work"). Also verify with n =0 that your back() function works on one of the aforementioned vectors.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!