title: subset column names from df to plot specific coefficients from regression R
body: <p>I am trying to plot only a select few coefficients from a regression. but my regression has 100s of variables so I'm trying to think of a way to extract the coefficients using better coding.</p>
  <p>I have this regression below:</p>
  <pre><code>n &lt;- 1e3
  d &lt;- data.frame(
    # Covariates
    x1 = rnorm(n),
    x2 = rnorm(n),
    x3 = rnorm(n),
    x4 = rnorm(n),
    # Individuals and firms
    id = factor(sample(20, n, replace=TRUE)),
    firm = factor(sample(13, n, replace=TRUE)),
    # Noise
    u = rnorm(n)
  )
  
  id.eff &lt;- rnorm(nlevels(d$id))
  firm.eff &lt;- rnorm(nlevels(d$firm))
  
  d$y &lt;- d$x1 + 0.5*d$x2 + id.eff[d$id] + firm.eff[d$firm] + d$u
  
  est &lt;- felm(y ~ x1 + x2 + x3 + x4 | id + firm, data = d)
  </code></pre>
  <p>But i only want to plot x1 &amp; x2, so i extract the column names i want:</p>
  <pre><code>d_names = names(d)
  N &lt;- -4
  d_cleaned_names &lt;- head(d_names, -N)
  
  d_cleaned_names_filter &lt;- d_cleaned_names[1:2]
  </code></pre>
  <p>I then add quotation marks and paste it into one continuous character:</p>
  <pre><code>d_cleaned_names_filter_quote &lt;- shQuote(d_cleaned_names_filter)
  d_cleaned_filter_quote_names = paste(d_cleaned_names_filter_quote, collapse =  ',' )
  </code></pre>
  <p>and when i plot this:</p>
  <pre><code>jtools::plot_coefs(est,plot.distributions = TRUE, inner_ci_level = .9, coefs = c(d_cleaned_names_filter_quote))
  </code></pre>
  <p>I get the error:</p>
  <pre><code>Error in if (rescale.distributions == FALSE &amp;&amp; max(heights)/min(heights) &gt;  : 
    missing value where TRUE/FALSE needed
  In addition: Warning messages:
  1: In max(heights) : no non-missing arguments to max; returning -Inf
  2: In min(heights) : no non-missing arguments to min; returning Inf
  </code></pre>
  <p>but this works perfectly writing 'x1' &amp; 'x2' out manually but not that feasible for a large dataset:</p>
  <pre><code>jtools::plot_coefs(est,plot.distributions = TRUE, inner_ci_level = .9, coefs = c('x1', 'x2'))
  </code></pre>
  <p>any advice would be very welcome.</p>