Reshaping from Wide to Long using Year in Variable Name : <p>I am trying to reshape a large dataframe (34645 x 11619) from wide to long. I would like to reshape the years 99 to 16. This means I have variables such as "edu<strong>99</strong>", "edu<strong>00</strong>", ... "edu<strong>16</strong>" or variables such as "p99d<strong>61</strong>", "p<strong>00</strong>d61", ..., "p<strong>16</strong>d61". The year string is not always on the same position.</p>

<p>Is there a way, to tell R to look for the the year strings "99-16" in the variable names when reshaping? (of course given that the string numbers uniquely identify the year).</p>

<p>Or in general, are there efficient strategy to reshape a big dataset?</p>

<p>Thank you so much for your help!</p>

<p>Best, Patrick</p>
