title: Quantmod, getSymbols, Extracting Close Price in R
body: <p>I have a string of tickers that I'm trying to get data for using Quantmod.  My list is long and there are some bad tickers so I use the incorporate the try function.</p>
  
  <p>I'm having trouble using the Cl function from Quantmod.  As far as I can tell it should work - but I'm sure I have a small problem with my syntax.  </p>
  
  <p>Code:</p>
  
  <pre><code>tickers = c("IBM","GM")  #This is an example for purpose here
  stock_data &lt;- lapply(tickers, function(tickers), try(getsymbols(tickers,
      auto.assign=FALSE)))
  close_prices &lt;- do.call(merge,Cl(stock_data))
  </code></pre>
  
  <p>stock_data comes back as a list of xts objects identified by the ticker with the rows of each element as a date value and the columns a series of ticker-related data (open, close, etc.).</p>
  
  <p>close_prices should be a list or data frame of only the closing price column of all tickers (i.e, the closing price column from IBM, the closing price column from GM, etc.).</p>
  
  <p>When I apply the do.call (which I have in various permutations - none of them correct) I get an error that tells me their are no column values within the xts object that contain "close" - which just isn't the case.  For each xts element (identified as "IBM" and "GM" in this case) there is a column named "XXX.close" (e.g., IBM.Close, GM.Close).  I don't know why I can't get the syntax right or get Cl to see the close columns.</p>
  
  <p>Any help appreciated.</p>
  
  <p>Thank you.</p>
  
  <p>**** Edit/UPDATE ***</p>
  
  <p>My list stock_data for the sample vector has the following structure:</p>
  
  <pre><code>str(stock_data)
  List of 2
   $ :An ‘xts’ object on 2015-01-05/2015-12-07 containing:
    Data: num [1:234, 1:6] 161 160 157 156 158 ...
   - attr(*, "dimnames")=List of 2
    ..$ : NULL
    ..$ : chr [1:6] "IBM.Open" "IBM.High" "IBM.Low" "IBM.Close" ...
    Indexed by objects of class: [Date] TZ: UTC
    xts Attributes:  
  List of 2
    ..$ src    : chr "yahoo"
    ..$ updated: POSIXct[1:1], format: "2015-12-09 16:21:31"
   $ :An ‘xts’ object on 2015-01-05/2015-12-07 containing:
    Data: num [1:234, 1:6] 35 34.4 35.2 36.1 36.2 ...
   - attr(*, "dimnames")=List of 2
    ..$ : NULL
    ..$ : chr [1:6] "GM.Open" "GM.High" "GM.Low" "GM.Close" ...
    Indexed by objects of class: [Date] TZ: UTC
    xts Attributes:  
  List of 2
    ..$ src    : chr "yahoo"
    ..$ updated: POSIXct[1:1], format: "2015-12-09 16:21:31"
  </code></pre>
  
  <p>The structure is the same for the actual vector - it is just longer with more dimensions.</p>