title: R: Extracting values from summary()
body: <p>I'm using the <a href="https://cran.r-project.org/web/packages/urca/urca.pdf" rel="nofollow">urca</a> package to conduct some calculations on unit roots.
  For example, let's use following dataset from the urca package:</p>
  
  <pre><code>library(urca)
  data(Raotbl3)
  attach(Raotbl3)
  </code></pre>
  
  <p>Applying the Augmented Dickey Fuller test looks like:</p>
  
  <pre><code>lc.df &lt;- ur.df(y=lc, lags=3, type='trend')
  summary(lc.df)
  </code></pre>
  
  <p>In return, we get a summary of all values. However, I want to extract only specific values. The possible fields are here:</p>
  
  <pre><code>slotNames(summary(lc.df))
  #  [1] "classname" "test.name" "testreg"   "teststat"  "cval"      "bpoint"        "signif"    "model"     "type"      "auxstat"  
  # [11] "lag"       "H"         "A"         "lambda"    "pval"      "V"             "W"         "P"       
  </code></pre>
  
  <p>Interestingly, </p>
  
  <pre><code>ur.df(y=lc, lags=3, type='trend')@teststat 
  #             tau3  phi2  phi3
  # statistic -2.239 3.738 2.597
  </code></pre>
  
  <p>or</p>
  
  <pre><code>ur.df(y=lc, lags=3, type='trend')@cval
  #       1pct  5pct 10pct
  # tau3 -4.04 -3.45 -3.15
  # phi2  6.50  4.88  4.16
  # phi3  8.73  6.49  5.47
  </code></pre>
  
  <p>works just fine. However, extracting values from "pval" or "lag" does not work (returns "NULL").</p>
  
  <p>When I looked <a href="https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/R/methods-summary.R?root=urca" rel="nofollow">here</a>, I discovered that the problem appears with every variable that is "=NULL". Not sure if it's important.</p>
  
  <pre><code>setMethod("summary", "ur.df", function(object){
    return(new("sumurca", classname="ur.df", test.name=object@test.name,     
               testreg=object@testreg, teststat=object@teststat, 
               cval=object@cval, bpoint=NULL, signif=NULL, 
               model=object@model, type=NULL, auxstat=NULL, lag=NULL, 
               H=NULL, A=NULL, lambda=NULL, pval=NULL, V=NULL, W=NULL, P=NULL))
  })
  </code></pre>
  
  <p>Any idea how to solve this?</p>