title: In R tidymodels how can I specify contrasts for specific variables?
body: <p>I would like to specify &quot;sum to zero&quot; contrasts for two predictors in a LM using a <code>tidymodels</code> recipe.  Is it possible?  In looking at the <code>recipes</code> documentation, before 1.3, it seems there were attempts to build the variable specific options but the strategy was shifted to a global option.</p>
  <p>I am trying to convert this base R code into <code>tidymodels</code>:</p>
  <pre class="lang-r prettyprint-override"><code>Bikeshare &lt;- ISLR2::Bikeshare  # start with original data
  contrasts(Bikeshare$hr) &lt;- contr.sum(24)
  contrasts(Bikeshare$mnth) &lt;- contr.sum(12)
  mod.lm2 &lt;-
    lm(
      bikers ~ mnth + hr + workingday + temp + weathersit,
      data = Bikeshare
    )
  summary(mod.lm2)
  </code></pre>
  <p>I got this far:</p>
  <pre class="lang-r prettyprint-override"><code>library(tidymodels)
  Bikeshare &lt;- ISLR2::Bikeshare  # start with original data
  contrasts(Bikeshare$hr) &lt;- contr.sum(24)
  contrasts(Bikeshare$mnth) &lt;- contr.sum(12)
  
  lm_spec &lt;- linear_reg() %&gt;%
    set_engine(&quot;lm&quot;)
  
  the_rec &lt;- 
    recipe(
      bikers ~ mnth + hr + workingday + temp + weathersit,
      data = Bikeshare
    ) %&gt;%
    step_dummy(c(mnth, hr), one_hot = TRUE)
  
  the_workflow&lt;- workflow() %&gt;% 
    add_recipe(the_rec) %&gt;% 
    add_model(lm_spec)
  
  the_workflow_fit_lm_fit &lt;- 
    fit(the_workflow, data = Bikeshare) %&gt;% 
    extract_fit_parsnip()
  
  summary(the_workflow_fit_lm_fit$fit)
  </code></pre>
  <p>Does anybody know how to get the same results out of a <code>tidymodels</code> workflow?</p>
  <p>I don't think I can use contr.sum as a global option.  This gives me the betas I would like for two of the variables but it changes the contrasts on others.</p>
  <pre><code>BikeShare &lt;- ISLR2::Bikeshare # be sure to work with original data ; 
  old_opt &lt;- options()$contrast; 
  options(contrasts = c('contr.sum', 'contr.poly'))
  </code></pre>