title: How to count nodes in a Tree in R
body: <p>I'm starting to study ML with R. I do the following operations with RStudio:</p>
  
  <pre><code>iris=datasets::iris
  tree(Species~., iris)
  </code></pre>
  
  <p>And I obtain:</p>
  
  <pre><code> 1) root 150 329.600 setosa ( 0.33333 0.33333 0.33333 )  
     2) Petal.Length &lt; 2.45 50   0.000 setosa ( 1.00000 0.00000 0.00000 ) *
     3) Petal.Length &gt; 2.45 100 138.600 versicolor ( 0.00000 0.50000 0.50000 )  
       6) Petal.Width &lt; 1.75 54  33.320 versicolor ( 0.00000 0.90741 0.09259 )  
        12) Petal.Length &lt; 4.95 48   9.721 versicolor ( 0.00000 0.97917 0.02083 )  
          24) Sepal.Length &lt; 5.15 5   5.004 versicolor ( 0.00000 0.80000 0.20000 ) *
          25) Sepal.Length &gt; 5.15 43   0.000 versicolor ( 0.00000 1.00000 0.00000 ) *
        13) Petal.Length &gt; 4.95 6   7.638 virginica ( 0.00000 0.33333 0.66667 ) *
       7) Petal.Width &gt; 1.75 46   9.635 virginica ( 0.00000 0.02174 0.97826 )  
        14) Petal.Length &lt; 4.95 6   5.407 virginica ( 0.00000 0.16667 0.83333 ) *
        15) Petal.Length &gt; 4.95 40   0.000 virginica ( 0.00000 0.00000 1.00000 ) *
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li>how can I obtain the maximum node depth of the tree? </li>
  <li>how can I obtain the number of nodes?</li>
  </ol>
  
  <p>I use packages <code>tree</code> and <code>datasets</code>.</p>
  
  <p>Thank you in advance.</p>