I'm trying to work through the source code for sjmisc::count_na
. I'm not very experienced at digging through source code so I've been using this thread as a guide, but I am still getting stuck. I hope this is not a duplicate.
In RStudio I can press F2 on count_na
to get its source, but it looks like some of the work is being done in a function called get_label
. The source code for this function is simply
function (x, ..., def.value = NULL, case = NULL)
{
UseMethod("get_label")
}
The thread above suggests trying methods()
or getAnywhere
library(sjmisc)
methods("get_label")
#> Error in .S3methods(generic.function, class, parent.frame()): no function 'get_label' is visible
getAnywhere("get_label")
#> A single object matching 'get_label' was found
#> It was found in the following places
#> namespace:sjlabelled
#> with value
#>
#> function (x, ..., def.value = NULL, case = NULL)
#> {
#> UseMethod("get_label")
#> }
#> <bytecode: 0x000000001a7522c0>
#> <environment: namespace:sjlabelled>
This makes clear that get_label()
is a function in the sjlabelled
namespace. I'm not sure how to proceed in order to find its source code. Based on the thread above, I understand that I first need to figure out which classes get_label
is written for, and then I can look at the source code for the class-specific methods. For some functions I've been able to do this using a dropdown menu inside RStudio after using F2, but there is no such menu available here. I have also tried:
methods("sjlabelled::get_label")
#> Error in .S3methods(generic.function, class, parent.frame()): no function 'sjlabelled::get_label' is visible
methods("sjlabelled:::get_label")
#> Error in .S3methods(generic.function, class, parent.frame()): no function 'sjlabelled:::get_label' is visible
showMethods("sjlabelled::get_label")
#>
#> Function "sjlabelled::get_label":
#> <not an S4 generic function>
What's going on here? What do I need to do the find the get_label
source code?