title: How to create a factor interaction variable in R? Why can't I just multiply?
body: <p>I'm doing an OLS regression, and I'm trying to create an interaction variable. To do this, as far as I know, I just multiple two variables together. However, that is not working. </p>
  
  <p>Let's say I have variables race (white, minority) and location (NE, S, W, MW). I want to create an interaction effect between all those in the NE and race. So I do:</p>
  
  <pre><code>&gt;NE = location[location==NE]
  &gt;race_NE = NE*race
  Error in race * NE : non-numeric argument to binary operator
  </code></pre>
  
  <p>Didn't work. Why?</p>
  
  <p>I then found the code interaction(). I'm not sure what that means, but it seems to give me something:</p>
  
  <pre><code>&gt; cat = interaction(NE, race)
  Warning message:
  In ans * length(l) + if1 :
    longer object length is not a multiple of shorter object length
  &gt; freq(cat)
  cat 
                    Frequency Percent
  2 NE.0 white       246    44.4
  2 NE.1 minority       308    55.6
  Total                   554   100.0
  </code></pre>
  
  <p>I'm not sure if that did what I need it to do so I can use an interaction variable in an lm() model?</p>
  
  <p>I'm kinda lost here. This may be more a stat and an R question. Please help, thanks</p>