match.fun Function in R (Example)
In this R tutorial you’ll learn how to extract the syntax of a function using the match.fun command.
Table of contents:
Let’s dive into it…
Example: Extract Source Code of Function Using match.fun() Command
The following R programming code explains how to use the match.fun argument to return the content of a function in R.
In this example, we’ll return the source code of the sd function:
match.fun(sd) # Apply match.fun function # function (x, na.rm = FALSE) # sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), # na.rm = na.rm)) # <bytecode: 0x556b1119d590> # <environment: namespace:stats>
The previous output of the RStudio console shows the code of the sd function.
Video & Further Resources
If you need more explanations on the examples of this tutorial, I recommend having a look at the following video on my YouTube channel. I’m explaining the contents of this article in the video tutorial.
The YouTube video will be added soon.
Furthermore, you may have a look at the other tutorials on this website:
- match.call Function in R
- Access & Manipulate Body of Function
- List of R Functions
- R Programming Language
At this point you should know how to access and extract the syntax of a function using the match.fun function in the R programming language. Let me know in the comments below, if you have additional questions.
Subscribe to the Statistics Globe Newsletter
Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.
Thank you!
Welcome to the Statistics Globe newsletter. From now on, I’ll send you regular emails about statistics, data science, AI, and programming with R and Python.
I’m Joachim Schork. On this website, I provide statistics tutorials as well as code in Python and R programming.
Statistics Globe Newsletter
Get regular updates on the latest tutorials, offers & news at Statistics Globe. I hate spam & you may opt out anytime: Privacy Policy.
Thank you!
Please check your email inbox and click the confirmation link to complete your subscription. If you don’t see the email within a few minutes, please also check your spam/junk folder.






