R dplyr:: rename and select using string variable
<p>I am trying to select a subset of variables in my dataframe, and rename the variables in the new dataframe. I have a large number of variables that I would need to rename. I am using </p>

<pre><code>dplyr::select
dplyr::select_
</code></pre>

<p>Since I have number of variables to rename, I am thinking if I should use a string variable to rename, but not sure if it could be possible? Using a string helps me to manage the newname oldname mapping. Here is an example</p>

<pre><code>dplyr::select
library(dplyr)
library(nycflights13) 
set.seed(123)
data &lt;- sample_n(flights, 3)

select(data,yr=year,mon=month,deptime=dep_time)
</code></pre>

<p>The question how could I pass the arguments for this in a string, that is the newvariable=oldvariable arguments and then use</p>

<pre><code>dplyr::select_

col_vector &lt;- c("year", "month", "dep_time")
select_(data, .dots = col_vector)
</code></pre>

<p>The string I have in mind are:</p>

<pre><code>rename_vector &lt;- c("yr=year","mon=month","deptime=dep_time")
</code></pre>

<p>Any suggestions would be very helpful.</p>