What's the difference between lapply and do.call?

前端 未结 7 1244
孤独总比滥情好
孤独总比滥情好 2020-11-29 14:46

I\'m learning R recently and confused by two function: lapplyand do.call. It seems that they\'re just similar to map function in Lisp.

7条回答
  •  遥遥无期
    2020-11-29 15:07

    In most simple words:

    1. lapply() applies a given function for each element in a list,so there will be several function calls.

    2. do.call() applies a given function to the list as a whole,so there is only one function call.

    The best way to learn is to play around with the function examples in the R documentation.

提交回复
热议问题