Professional Documents
Culture Documents
Assignment-II
1. Will the following code return any error? State the reason behind your answer and explain the
logic behind the code
val<- numeric()
2. Write a function is.even(n) in R that returns TRUE when n is even and FALSE otherwise. Then,
using is.even(n), write a function evens.in(v) that returns a vector comprised of the even integers in a
vector v of integers.
3. a. Write a function “invoice” with variables pcs (nr of pieces) and unitprice the function calculates the
net price (pcs * unitprice) and gives a deduction of 10% for >25 pieces sold
b. Test with 56 pieces of 89$/unit