title: How do I add variables to my regression solely when another variable is a specific value?
body: <p>My dataset contains R&amp;D expenses for the same company for several periods: -3 to +3. I use this fixed effects linear model:</p>
  <pre><code>m5a &lt;- felm(ihs(RD_expenses) ~ merger_it_pre1 + merger_it + merger_it_post1 + merger_it_post2 + merger_it_post3 + factor(year),
             data = TandC,
             subset = RD_expenses &gt; pcts[1] &amp; RD_expenses &lt; pcts[2])
  </code></pre>
  <p>Now I want to add a covariate for RD expenses but only when the period is -1. The period variable is another column in the same dataset.</p>
  <p>Any ideas how I can do this? I tried to add <code>ihs(RD_expenses)if(period = -1))</code> to the model but this did not work. I get the error: unexpected if.</p>
  <p>I'm quite new to R so if someone could help me out that would be much appreciated!</p>