title: Access different columns in xts object in R
body: <p>How Can I access individual columns in R?</p>
  
  <p>My <code>xts</code> object is:</p>
  
  <pre><code>&gt; glimpse(`prod`)
  Observations: 2,341
  Variables: 3
  $ DL_prod     (dbl) 301.50, 303.75, 308.50, 311.00, 319.00, 318.25, 320.00, 320.75, 318.00, 319.00, 315.00, 313.50, 313.00,...
  $ MWF_prod     (dbl) 301.500, 309.000, 311.250, 319.750, 354.563, 322.000, 324.000, 321.500, 320.065, 730.000, 316.160, 315....
  $ MA_prod      (dbl) 301.500, 302.688, 304.946, 308.750, 316.500, 315.500, 318.500, 315.250, 313.000, 215.500, 311.500, 310....
  
  &gt; str(`prod`)
  An ‘xts’ object on 2007-01-01/2016-01-08 containing:
    Data: num [1:2341, 1:6] 302 304 308 311 319 ...
   - attr(*, "dimnames")=List of 2
    ..$ : NULL
    ..$ : chr [1:3] "DL_prod" "MWF_prod" "MA_prod"
    Indexed by objects of class: [Date] TZ: UTC
    xts Attributes:  
  List of 2
   $ src    : chr "yahoo"
   $ updated: POSIXct[1:1], format: "2016-01-11 17:26:06"
  </code></pre>
  
  <p>I wish to calculate Simple moving averages for <code>DL_prod</code> column.</p>
  
  <p>But I can't select that column like:</p>
  
  <pre><code>prod$DL_prod
  </code></pre>
  
  <p>I want to calculate SMA by something like:</p>
  
  <pre><code>SMA(prod$DL_prod)
  </code></pre>
  
  <p>This will also help me using the <code>quantmod</code> package for <code>timeseries</code> analysis.
  For example I would like to use the <code>chartSeries(prod)</code> method to plot DL_prod column.
  Looked everywhere but can't seem to find any info on this. Is this possible?</p>