fs &lt;- data.frame(features = names(feature_sds),
                            sd = as.numeric(feature_sds))
  feature_coefs &lt;- merge(feature_coefs,
                     data.frame(features = rownames(orig_coefs),
                                orig_coefs = as.numeric(orig_coefs)),
                     by = &#39;features&#39;, all.x = TRUE)
  feature_coefs$scaled_coefs &lt;- feature_coefs$orig_coefs * feature_coefs$sd
  coefs&lt;-feature_coefs %&gt;% filter(scaled_coefs != 0)
  coefs
}</code></pre>
<p><