1.

If a programmer wants the output to be a list then ___________ function is used.(a) Lapply(b) Sapply(c) Vapply(d) ZapplyI got this question during an online interview.I want to ask this question from Functions in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Right answer is (b) Sapply

The explanation is: sapply() FUNCTION does the same JOBS as lapply() function but RETURNS a VECTOR. We can use a user built-in function into lapply() or sapply(). We create a function named avg to compute the average of the minimum and maximum of the vector.



Discussion

No Comment Found

Related InterviewSolutions