# is.function & is.primitive Functions in R (2 Examples)

In this R tutorial youâ€™ll learn how to **test whether an object is a (primitive) function using the is.function & is.primitive functions**.

The content of the post is structured as follows:

Hereâ€™s the step-by-step process.

## Example 1: Test if Object is Function Using is.function()

Example 1 illustrates how to check whether a data object is a function using the is.function command.

Letâ€™s first create a data object in R:

x <- 1:5 # Create data object x # Print data object # [1] 1 2 3 4 5

The previous output of the RStudio console shows that our data object is an integer vector.

Letâ€™s apply the is.function function to this vector:

is.function(x) # Apply is.function # [1] FALSE

The RStudio console has returned the logical indicator FALSE, i.e. the data object x is not a function.

Letâ€™s apply the is.function command once again to the mean function:

is.function(mean) # Apply is.function # [1] TRUE

This time, the is.function command has returned the logical value TRUE, i.e. mean is a function in R.

## Example 2: Test if Object is Primitive Function Using is.primitive()

In this example, Iâ€™ll explain how to test if a object is a primitive function.

Letâ€™s apply the is.primitive function to the mean function:

is.primitive(mean) # Apply is.primitive # [1] FALSE

The RStudio console has returned FALSE, i.e. the mean function is not a primitive function.

Letâ€™s apply the is.primitive function once again to the sum function:

is.primitive(sum) # Apply is.primitive # [1] TRUE

As you can see, the sum function is a primitive function.

## Video, Further Resources & Summary

Have a look at the following video on my YouTube channel. I show the R programming syntax of this article in the video tutorial.

*The YouTube video will be added soon.*

Furthermore, you might read some of the other tutorials on https://www.statisticsglobe.com/:

- as.double & is.double Functions in R
- as.name & is.name Functions in R
- as.tbl & is.tbl R Functions of dplyr Package
- List of R Functions (Programming Examples)
- The R Programming Language

Summary: This tutorial has shown how to **apply the is.function & is.primitive functions** in the R programming language. Let me know in the comments section, in case you have additional questions.