Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improved `is.language` function in R

Tags:

r

In R, is there a function that will return TRUE if its argument has type language and FALSE otherwise?

The is.language function does not satisfy this because it will return TRUE for arguments of type symbol or expression as well. Obviously, I could simple check that the type of the argument is is language using something like typeof(x) == 'language' or write my own function, but it seems odd that R wouldn't already have its own function for this purpose because most types in R have an associated is-type function specific to those types.

like image 962
Jon Claus Avatar asked Dec 14 '25 23:12

Jon Claus


1 Answers

The only object of type language that is not a name/symbol or expression is a call, for which you can use is.call.

like image 145
Matthew Plourde Avatar answered Dec 16 '25 17:12

Matthew Plourde



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!