The best way to learn how to use a function written by other people is to read its source code. If you use Rstudio, you just need to type the function name at the command line. However, a lot of times, you will get something like this.
You may wonder, “where is the function body?” You don’t see the function body because mean() is a generic function. Generic functions are used to implement the S3 object oriented system in R. Each generic function has one or many methods. For example, mean() has the following methods:
We cannot view the source code of a generic function, instead, we can view the source code of each generic.method function. For example, run the following commands to view the source of mean.default() and mean.Date() respectively.