Skip to content

How to see the implementation of print function for a class from a package?

4 messages · Majid Einian, R. Michael Weylandt

#
I presume your problem is that you are looking for non-exported
methods in some unstated package.

Generally the pattern is something like this

methods(plot) # shows all plot.* methods

methods(class = "lm") # shows all *.lm methods

Those marked with a star are not exported but you can get at them with
the getAnywhere() function [you can also use three colons instead of
two, but that requires you to know the function at hand]

Incidentally, you might also want to download the package source from
CRAN and browse it to see the author's commented code.

Michael
On Sat, Jun 9, 2012 at 10:53 PM, Majid Einian <einian85 at gmail.com> wrote:
#
Perhaps it's an S4 object? You can test that with isS4() and, if it is, try

showMethods("show")

showMethods(class = "datation")

getMethod("show", "datation")

Note that it's also entirely possible that your object doesn't have a
print method and instead falls back on print.default or some other
inherited method, though that doesn't seem to be the case here. E.g.,

x <- 1:5
class(x) <- "flub"

print(x) # Uses print.default b/c there's no print.flub

It would be helpful if you could say where the package is from so the
rest of us could look at it and help you more effectively.

Michael
On Sun, Jun 10, 2012 at 12:49 AM, Majid Einian <einian85 at gmail.com> wrote: