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?
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?
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
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).