Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming of the apply function family in R

I'm currently studying R. In particular I need to remember the functions in the apply-function family (e.g. lapply, sapply, mapply, etc.). I know what each function in the apply-function family does (especially this answer helps a lot), but mix up the names from time to time.

Is there a natural meaning for the prefix of each apply function (like lapply = 'list'-apply)?

like image 709
Hericks Avatar asked Oct 19 '25 20:10

Hericks


1 Answers

Yes, you got following apply r-basic functions:

  • apply for apply ;)
  • lapply for lists or vectors (documentation)
  • vapply for specific return value (documentation)

  • sapply for simple (documentation)

  • mapply for multiple list or vector arguments (documentation)

  • tapply for table (check old question here)

  • rapply for recursive (documentation)

I think you can interprete some prefix differently, like m was mentioned in the commentary as multivariate (commentary got removed). I tried to use the wording of the documentation, so it's more likely to be understood.

Also lapply, sapply and vapply are in the same documentation site, since the sapply and vapply are wrapper for lapply

like image 111
mischva11 Avatar answered Oct 22 '25 10:10

mischva11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!