The lapply function accepts three arguments: the first argument is the object, the second is the user-specified function, and the optional third argument specifies the additional arguments to the user-specified function. The lapply function always returns a list, irrespective of the type of the first argument.
In step 1, the lapply function is used to apply sqrt to each element of a vector. The lapply function always returns a list.
In step 2, a list with three elements is involved, each of which is a vector. It calculates the mean of these vectors. The lapply function returns a list while sapply returns a vector in this case.
In step 3, sapply is used to apply a function to columns of a data frame. For obvious reasons, we ...