title: Select a value from time series by date in R
body: <p>How to select a value from time series corresponding needed date?</p>
  
  <p>I create a monthly time series object with command:</p>
  
  <pre><code>producers.price &lt;- ts(producers.price, start=2012+0/12, frequency=12)
  </code></pre>
  
  <p>Then I try to do next:</p>
  
  <pre><code>value &lt;- producers.price[as.Date("01.2015", "%m.%Y")]
  </code></pre>
  
  <p>But this doesn't make that I want and value is equal</p>
  
  <pre><code>[1] NA
  </code></pre>
  
  <p>Instead of <code>10396.8212805739</code> if producers.price is:</p>
  
  <pre><code>producers.price &lt;- structure(c(7481.52109434237, 6393.18959031561, 6416.63065650718, 
                    5672.08354710121, 7606.24186413516, 5201.59247092013, 6488.18361474813, 
                    8376.39182893415, 9199.50916585545, 8261.87133079494, 8293.8195347453, 
                    8233.13630279516, 7883.17272003961, 7537.21001580393, 6566.60260432381, 
                    7119.99345843556, 8086.40101607729, 9125.11104610046, 10134.0228610828, 
                    10834.5732454454, 9410.35031874371, 9559.36933274129, 9952.38679679724, 
                    10390.3628690951, 11134.8432864557, 11652.0075507499, 12626.9616107684, 
                    12140.6698452193, 11336.8315981684, 10526.0309052316, 10632.1492109584, 
                    8341.26367412737, 9338.95688558448, 9732.80173656971, 10724.5525831506, 
                    11272.2273444623, 10396.8212805739, 10626.8428853062, 11701.0802817581, 
                    NA), .Tsp = c(2012, 2015.25, 12), class = "ts")
  </code></pre>