<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Carl,<br>
Have you look into the data.table::dcast function to reshape
tables from long to wide formats? See e.g. <a
href="ftp://cran.r-project.org/pub/R/web/packages/data.table/vignettes/datatable-reshape.html">ftp://cran.r-project.org/pub/R/web/packages/data.table/vignettes/datatable-reshape.html</a>
<br>
</p>
<p>--Mel.<br>
</p>
<br>
<div class="moz-cite-prefix">On 1/17/2017 8:27 PM, Carl Sutton
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:1096506642.5044240.1484702859667@mail.yahoo.com">
<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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
datatable-help mailing list
<a class="moz-txt-link-abbreviated" href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></pre>
</blockquote>
<br>
</body>
</html>