title: How to get the names of factor levels corresponding to fixed effect regression coefficients for a GAM in R?
body: <p>I have a gam in R (mgcv package) with 7 parameters, and one of them is a fixed effect with 30 levels (30 names). I want to analyse the regression coefficients for each name (person), but R numbers each level (so 1-29, and the 30th one is the reference level), so I can't figure out which person corresponds to which regression coefficient.</p>
  <pre><code># model looks like this:
  mymod &lt;- gam(response ~ s(x1) + s(x2) + s(x3) + s(x4) + x5 + x6 + x7_person, offset=offset, data=mydata, method=&quot;REML&quot;, select=&quot;TRUE&quot;)
  
  # neither of these give me the name of each person
  mymod$coefficients
  summary(mymod)$p.coeff
  
  </code></pre>
  <p>So instead of x7_personSam, x7_personSue (for example), I get x7_person1, x7_person2, etc.</p>
  <p>I need to be able to find the metadata that corresponds to each person's regression coefficient, and also figure out which person doesn't have a regression coefficient because they are the reference level.</p>
  <p>Is there a way to make R print the name of each factor level, as it appears in the data?</p>
  <p>Thanks!</p>