title: calling information from different data frames whose results match a character vector
body: <p>I am trying to apply a function to convert financial accounts from a number of companies to USD.</p>
  
  <p>The firms relating to each currency can be found below.</p>
  
  <pre><code>USDfirms &lt;- c("GOOG", "AMZN", "AAPL", "CSCO", "FB", "HP", "IBM", "0992.HK", 
      "MSFT", "CRM", "TWTR", "WB", "ZTE.CN")
  CNYfirms &lt;- c("BABA", "BIDU", "1169.HK", "HMI", "3888.HK", "1357.HK", "NTES", 
          "TCEHY", "1810.HK", "0763.HK")
  TWDfirms &lt;- c("2357.TW", "2324.TW", "2356.TW", "2498.TW", "3231.TW")
  KRWfirms &lt;- c("003550.KS", "005930.KS")
  JPYfirms &lt;- c("5563.T", "7752.T")
  EURfirms &lt;- "NOK"
  </code></pre>
  
  <p>So <code>CNYfirms</code> correspond to Chinese firms whose financial accounts are in CNY. The <code>dput()</code> is a dump of approximately 30 companies finances and can be found <a href="http://%20https://files.fm/u/amysx7hu" rel="nofollow noreferrer">here</a>.</p>
  
  <p>EDIT: link 2 here <a href="http://s000.tinyupload.com/download.php?file_id=06545415747486823455&amp;t=0654541574748682345555828" rel="nofollow noreferrer">http://s000.tinyupload.com/download.php?file_id=06545415747486823455&amp;t=0654541574748682345555828</a></p>
  
  <p>Its called <code>BSISCF</code></p>
  
  <p>The <code>df</code> - <code>dput</code>() is called <code>BSISCF</code>.</p>
  
  <p>I also have a currency conversion table:</p>
  
  <p>Which looks like the following;</p>
  
  <pre><code># A tibble: 1 x 6
    date       cny_usd twd_usd  krw_usd jpy_usd eur_usd
    &lt;date&gt;       &lt;dbl&gt;   &lt;dbl&gt;    &lt;dbl&gt;   &lt;dbl&gt;   &lt;dbl&gt;
  1 2018-04-01   0.159  0.0344 0.000943 0.00941    1.23
  </code></pre>
  
  <p>Data</p>
  
  <pre><code>fx &lt;-structure(list(date = structure(17622, class = "Date"), cny_usd = 0.159228, 
      twd_usd = 0.03442, krw_usd = 0.000943, jpy_usd = 0.009408, 
      eur_usd = 1.232305), row.names = c(NA, -1L), class = c("tbl_df", 
  "tbl", "data.frame"), .Names = c("date", "cny_usd", "twd_usd", 
  "krw_usd", "jpy_usd", "eur_usd"))
  </code></pre>
  
  <p>I have the following function and what I am trying to do is take the <code>symbol</code>column and use <code>ifelse</code> statements. So if the <code>symbol</code> column matches with a symbol in <code>CNYfirms</code> then in the <code>exchange.rates</code> column put the <code>cny_usd</code> exchange rate from the <code>fx</code> table. Do this for all the symbols. NA values will correspond to USD firms since there is no USD exchange rate in the <code>fx</code> table.</p>
  
  <pre><code>BSISCF &lt;- BSISCF %&gt;% 
    separate(symbol, into = c("ticker", "country"), 
             sep = "[.]", convert = TRUE, remove = FALSE) %&gt;%               # The NA values just correspond to US data
    mutate(exchange.rates = ifelse(symbol == CNYfirms, fx$cny_usd,
                                   ifelse(symbol == TWDfirms, fx$twd_usd,
                                          ifelse(symbol == KRWfirms, fx$krw_usd,
                                                 ifelse(symbol == JPYfirms, fx$jpy_usd,
                                                        ifelse(symbol == EURfirms, fx$eur_usd, 0)))))) %&gt;%
    select(exchange.rates, everything())
  </code></pre>
  
  <p>Okay this information is the next steps I will take once the exchange rates have been collected</p>
  
  <pre><code>  mutate(exchange.rates = ifelse(is.na(country), 1, exchange.rates)) %&gt;% 
    mutate_at(.funs = funs(fx = .*exchange.rates), .vars = vars(Cash.And.Cash.Equivalents:Change.In.Cash.and.Cash.Equivalents)) %&gt;%
    mutate(adjusted_fx = adjusted*exchange.rates) #All financial statements and the stocks adjusted price converted into USD
  </code></pre>
  
  <p>If there is something I did not explain well, let me know.</p>