Creating a new column based on another column in R
<p>I have a data frame that has things like "nasal_coronal" and "coronal" and I want to get rid of "nasal_" and create a new column for things marked with "nasal"</p>

<p>I initially tried to use <code>grep()</code> like this:
<code>data.df$nasal &lt;- grep("^nasal", data$type, value = TRUE)</code> but R gives me the error that the replacement has less rows than the data set.</p>

<p>Here's code to create a mini dataset.</p>

<pre><code>type &lt;- c("nasal_coronal", "nasal_coronal", "coronal")
word &lt;- c("something", "walk", "thing")

data.df &lt;- data.frame(word, type) 
</code></pre>