<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1484700197884_8685">Hi</div><div id="yui_3_16_0_ym19_1_1484700197884_8684"><br></div><div id="yui_3_16_0_ym19_1_1484700197884_7950" dir="ltr">This question is for information, not a coding problem.<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_19304"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_19661">Basic information:<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_20210">The data table I am attempting to melt has 363 columns and 85,074 rows (246.5MB). The first 14 are id variables and pose no problem. One of the measure vars has sequences of 2:9, The other 34 have sequence of 1:10. think paste0("var_",1:10)<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_10610"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_20022">What works:<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_11154">It is a simple matter to melt these measure var columns using columns 15:363. Thanks to an answer on a prior question I can use tstrsplit to split the sequence number off the column heading, So far, so good. <br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_11698"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_20024">The difficulty:<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_11876">The problems arises when I attempt to spread the variable column which contains prior column names sans sequence numbers. I have searched but not found a data.table function to spread the contents of "variable" into separate columns. The tidyr "spread" command maxes out my available memory of 12GB. I have attempted to use patterns to melt into separate columns but that results in column names of valuex, not the original column name. In searching the arguments for melt I have not seen one for preserving the original column names. Perhaps I missed something?</div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_22069"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_20207">The solution:<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_14918">Am I stuck with either <br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_14919"> a) splitting my data.table such that tidyr does not max out available memory, or</div><div dir="ltr" id="yui_3_16_0_ym19_1_1484700197884_22250"> b) use set names on 35 columns to get viable column names?<br></div><div id="yui_3_16_0_ym19_1_1484700197884_8491"><span></span></div><div id="yui_3_16_0_ym19_1_1484700197884_8492"><div id="yui_3_16_0_ym19_1_1484700197884_19122"> Any and all thoughts are appreciated. I have 20 of these datasets to mung and am starting on one of the smaller ones. The goal is write the code once and use it on all datasets.</div><div id="yui_3_16_0_ym19_1_1484700197884_21886"><br></div></div><div class="signature" id="yui_3_16_0_ym19_1_1484700197884_8686">Carl Sutton</div></div></body></html>