<p>This is slightly tricky since I am not aware of any formal definition of a <code>S3 class</code>. For R objects the S3 classes are governed by a very simple character vector of class names stored in the <code>class</code> attribute. Method dispatch is then done by matching element(s) of that attribute with a function name.</p>

<p>You could essentially do:</p>

<pre><code>x &lt;- 1:5
class(x) &lt;- "MyMadeUpClass"
x

# [1] 1 2 3 4 5
# attr(,"class")
# [1] "MyMadeUpClass"
</code></pre>

<p>Does the above really define a class in the intuitive formal understanding of the term ?</p>

<p>You can create a <code>print</code> method for objects of this class like (silly example incoming):</p>

<pre><code>print.MyMadeUpClass &lt;- function(x, ...)  {
  print(sprintf("Pretty vector: %s", paste(x, collapse = ",")))
}
x 
# [1] "Pretty vector: 1,2,3,4,5"
</code></pre>

<p>The important distinction here is that methods in S3 </p>

<ul>
<li>"belong to" (generic) functions, not classes</li>
<li>are chosen based on classes of the arguments provided to the function call</li>
</ul>

<p>Point I am trying to make is that S3 does not really have a formally defined inheritance (which I assume is what you are looking for), with contrast to <code>S4</code> which implements this via the <code>contains</code> concept, so I am not really sure what would you like to see as a result.</p>

<p>Very good read on the topic Object-Oriented Programming, Functional
Programming and R by John M. Chambers: <a href="https://arxiv.org/pdf/1409.3531.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/1409.3531.pdf</a></p>

<p>Edit (after question edit) - the <strong>sloop</strong> package: </p>

<p>From S3 perspective I think it makes a lot of sense to examine the structure of generics and methods. A found the <code>sloop</code> package to be a very useful tool for this: <a href="https://github.com/r-lib/sloop" rel="nofollow noreferrer">https://github.com/r-lib/sloop</a>.</p>
R: Finding class inheritance structure within an R package
<p>You can find all the objects in a package with </p>

<pre><code>objs &lt;- mget(ls("package:base"), inherits = TRUE)
</code></pre>

<p>You can select the functions from these with </p>

<pre><code>funs &lt;- objs[is.function(objs)]
</code></pre>

<p>You can get a complete list of the dependencies of the listed functions in a package by applying <code>codetools::findGlobals()</code>, <code>miniCRAN::makeDepGraph</code>, <code>pkgnet::CreatePackageReport</code> (or others) to the function list. All of these functions either graph the resulting dependencies or return an object easily plotable with, e.g., <code>igraph</code> or <code>DependenciesGraph</code>.</p>

<p>Is there an comparable set of commands to find all the classes created by a package and the inheritance structure of those classes? I know that for most packages the resulting web of class inheritance would be relatively simple, but I think that in a few cases, such as <code>ggplot2</code> and the <code>survey</code> package, the resulting web of class inheritance could be quite helpful.</p>

<p>I have found a package, <code>classGraph</code>, that creates directed acyclic graphs for S4 class structures, but I am more interested in the much more common S3 structures.</p>

<p>This seems brute-force and sloppy, but I suppose if I had a list of all the <code>class</code> attributes used by objects in the base packages, and all the <code>class</code> attributes of objects in a package, then any of the latter which is not among the former would be new classes created by the package or inherited from another non-base package.</p>