title: How to find the %change of two tables for every row in r?
body: <p>So I have two data tables that have exactly the same names and dates, for example table a has its lowest point at that month:</p>
  <pre><code>Date       companya companyb companyc ...company200
  2019-01      7         5        3            ...
  2019-02      4         4        1            ...
  </code></pre>
  <p>table b has the highest point at that month:</p>
  <pre><code>Date       companya companyb companyc ...company200
  2019-01      10        15        20           ...
  2019-02      5         10        40           ...
  </code></pre>
  <p>I want to find the % change from the table a to table b, I tried using Delt from library quantmod:</p>
  <pre><code>change&lt;-bind_rows(a,b)%&gt;% 
    group_by(Date) %&gt;%
    summarise_each(funs(delt(.))) %&gt;% 
    data.frame()
  </code></pre>
  <p>But this gives me a row of NAs and the absolute change:</p>
  <pre><code>Date       companya companyb companyc ...company200
  2019-01      NA       NA       NA          NA
  2019-01      .42      2        5.6         x
  2019-02      NA       NA       NA          NA
  2019-02      0        1.5      39          x
  </code></pre>
  <p>How would I find the arithmetic change so it looks something like:</p>
  <pre><code>Date       companya companyb companyc ...company200
  2019-01      -.42        -2      -5.6         x
  2019-02        0         -1.5    -39          x
  </code></pre>
  <p>Thanks for all your help! I really appreciate it!!</p>
  <p>*if anyone is having my same problem please check out Duck's solution it worked! ***</p>
  <p>Just to give additional information, my ultimate goal is to left_join another column at the end with the percent change of an index(which I also have the highs and low of and need to find the change) and compare it :
  My index looks like this :</p>
  <pre><code>Data     Index
  2019-01   -2.5
  2019-02   -5
  etc       etc
  </code></pre>
  <p>I'm thinking of left joining it so</p>
  <pre><code>df4&lt;-merge(df3,index, by=&quot;Date&quot;)
  </code></pre>
  <p>So it should look like this :</p>
  <pre><code>Date       companya companyb companyc ...company200  index
  2019-01      -.42       -2      -5.6         x         -2.5 
  2019-02      0          -1.5    -39          x         -5
  etc          etc        etc     etc          etc       etc
  </code></pre>
  <p>and my goal is to flag each column by see if the percent change of each company is more than -20% than the index, I'm thinking something like this:</p>
  <pre><code>Flags &lt;-df5    %&gt;%group_by(date) 
                 %&gt;% transmute ((diff(col(2:200)-index)&gt;20~1,
                                 diff(col(2:200)-index)=&lt;20~0)
  </code></pre>
  <p>so it looks like:</p>
  <pre><code>Date       companya companyb companyc ...company200  index
  2019-01      0        0       0            x         -2.5 
  2019-02      0        0       1            x         -5
  etc
  </code></pre>
  <p>Please let me know if my logic is ok!</p>