title: R: Create a stacked area plot of time series in ggplot2
body: <p>I have a data frame that is a percentage allocation for each variable. There are four variables where the sum of the rows are equal to 1. Here is a example output of the data frame:</p>
  
  <pre><code>dates       A   B   C   D
  1997-01-01  0.2 0.2 0.5 0.1 
  1997-02-01  0.3 0.2 0.4 0.1
  1997-03-01  0.1 0.3 0.2 0.4
  ...         ... ... ... ...
  2017-12-01  0.2 0.2 0.1 0.5
  </code></pre>
  
  <p>How can I create a similar stacked area plot like where the x-axis shows the years, and y-axis is from 0 to 1 (from <a href="https://ggplot2.tidyverse.org/reference/geom_density.html" rel="nofollow noreferrer">https://ggplot2.tidyverse.org/reference/geom_density.html</a>): </p>
  
  <p><a href="https://i.stack.imgur.com/gNn0E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gNn0E.png" alt="enter image description here"></a></p>
  
  <p>My attempt at following the instructions produced this, which is not exactly what I am looking for:</p>
  
  <p><a href="https://i.stack.imgur.com/gFozB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gFozB.png" alt="enter image description here"></a> </p>
  
  <p>I get the error message: </p>
  
  <blockquote>
    <p>Error: A:D must evaluate to column positions or names, not a double vector </p>
    
    <p>In addition: Warning messages: </p>
    
    <p>1: In x:y : numerical expression has 252 elements: only the first used </p>
    
    <p>2: In x:y : numerical expression has 252 elements: only the first used</p>
  </blockquote>