Is there any reason why I should use

map(<list-like-object>, function(x) <do stuff>)

instead of

lapply(<list-like-object>, function(x) <do stuff>)

the output should be the same and the benchmarks I made seem to show that lapply is slightly faster (it should be as map needs to evaluate all the non-standard-evaluation input).

So is there any reason why for such simple cases I should actually consider switching to purrr::map? 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, i.e. map(<list-like-object>, function(x) <do stuff>). Is there any advantage that purrr::map has in terms of performance, exception handling etc.? The comments below suggest that it does not, but maybe someone could elaborate a little bit more?

4 Answers
4

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *