![]() Note that this is the same as using the as.list function: sapply(c(3, 5, 7), exp, simplify = FALSE)Īs.list(sapply(c(3, 5, 7), exp)) # Equivalent ] However, on the one hand, if you set the simplify argument of the sapply function to FALSE you will get the same output as the lapply function. In this case, if you use the sapply function you will get a vector as output: sapply(c(3, 5, 7), exp) 20.08554 148.41316 1096.63316īut if you use the lapply function, you will get a list where each element correspond to the components of the previous vector. The difference between lapply and sapply functions is that the sapply function is a wrapper of the lapply function and it returns a vector, matrix or an array instead of a list.Ĭonsider that you want to calculate the exponential of three numbers. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |