Reputation: 1897
I have the following code which generates the error
Error in a == dplyr::mutate : comparison (1) is possible only for atomic and list types
a <- dplyr::mutate
a == dplyr::mutate
How can I check that this is TRUE in R?
Upvotes: 1
Views: 19
Reputation: 18585
You may also want to compare function body1 if you insist on using ==
:
body(a) == body(dplyr::mutate)
# [1] TRUE
1The body
function access and manipulates function body
(documentation).
Upvotes: 0
Reputation: 1228
You can use identical()
function:
The safe and reliable way to test two objects for being exactly equal. It returns TRUE in this case, FALSE in every other case.
With your example:
a <- dplyr::mutate
identical(a,dplyr::mutate)
# [1] TRUE
identical(a,dplyr::select)
# [1] FALSE
Upvotes: 2