Why use purrr::map instead of lapply?

前端 未结 3 1315
借酒劲吻你
借酒劲吻你 2020-11-27 09:15

Is there any reason why I should use

map(, function(x) )

instead of

lapply(

        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 09:43

    If we do not consider aspects of taste (otherwise this question should be closed) or syntax consistency, style etc, the answer is no, there’s no special reason to use map instead of lapply or other variants of the apply family, such as the stricter vapply.

    PS: To those people gratuitously downvoting, just remember the OP wrote:

    I am not asking here about one's likes or dislikes about the syntax, other functionalities provided by purrr etc., but strictly about comparison of purrr::map with lapply assuming using the standard evaluation

    If you do not consider syntax nor other functionalities of purrr, there's no special reason to use map. I use purrr myself and I'm fine with Hadley's answer, but it ironically goes over the very things the OP stated upfront he was not asking.

提交回复
热议问题