<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><p>Hi,</p>
<p>You write: <code>There was some discussion of an .EACHI facility for data.table. Not
sure what happened about that but I have an example that might be
useful: http://stackoverflow.com/questions/24472254/splitting-a-column-by-factor-within-a-data-frame/24472571#24472571</code></p>
<p><code>by=.EACHI</code> was implemented to remove the implicit “by-without-by” feature during joins. And that has been implemented quite sometime back - check the first FR implemented in the <a href="https://github.com/Rdatatable/data.table">README</a> following which Matt also <a href="http://lists.r-forge.r-project.org/pipermail/datatable-help/2014-March/002430.html">posted on the mailing list</a> asking for feedback.</p>
<p>You write: <code>which shows the code where DT has columns v1, v2 and v3: DT[, split(v2, v1), by = names(DT)]</code>
```</p>
<p>A small comment on this solution per-se. This calls <code>split</code> <em>for each row</em>! I’d approach this a little different:</p>
<pre><code>## 1.9.3
rbindlist(setDT(dd)[, {
ans = list(v2);
setattr(ans, 'names', v1);
list(list(ans))
}, by = list(v1=as.character(v1))
]$V1,
fill=TRUE)
# a b
# 1: 1 NA
# 2: 2 NA
# 3: 6 NA
# 4: NA 3
# 5: NA 4
# 6: NA 5
</code></pre>
<p>We can then add this back to <code>dd</code> by reference. Personally I’ve never had to call <code>split</code> on a <code>data.table</code>.</p>
<p>You write: <code>It works well if the rows of DT are unique but if they are not then
one must do something ugly like appending a uniquifying column of
1:nrow(DT), say, and then including that in by and then finally
removing it again at the end.</code></p>
<p>This suggests two features: </p>
<ol>
<li>The ability to tell it to do the by by row</li>
<li>The ability to selectively omit by variables from the output
```</li>
</ol>
<p>Not sure I follow this entirely, but <code>by=</code> does accept expressions. So, you could do:</p>
<pre><code>dd[, split(v2,v1), by=1:nrow(dd)]
# nrow a b
# 1: 1 1 NA
# 2: 2 2 NA
# 3: 3 6 NA
# 4: 4 NA 3
# 5: 5 NA 4
# 6: 6 NA 5
</code></pre>
<p>You write: <code>(By the way, is there an intention to move to the issue system on
github for things like this?)</code></p>
<p>The entire issues from R-Forge have been <a href="https://github.com/Rdatatable/data.table/issues?labels=feature+request&milestone=&page=1&state=open">already moved to github</a>, including feature requests. And since then users have filed new FRs/bugs here. So, yes, you can file FRs directly, although in this case, I think the feature already exists (IIUC)?</p>
<p><style>body{font-family:Helvetica,Arial;font-size:13px}</style><style>body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
padding:1em;
margin:auto;
background:#fefefe;
}
h1, h2, h3, h4, h5, h6 {
font-weight: bold;
}
h1 {
color: #000000;
font-size: 28pt;
}
h2 {
border-bottom: 1px solid #CCCCCC;
color: #000000;
font-size: 24px;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
color: #777777;
background-color: inherit;
font-size: 14px;
}
hr {
height: 0.2em;
border: 0;
color: #CCCCCC;
background-color: #CCCCCC;
}
p, blockquote, ul, ol, dl, li, table, pre {
margin: 15px 0;
}
a, a:visited {
color: #4183C4;
background-color: inherit;
text-decoration: none;
}
#message {
border-radius: 6px;
border: 1px solid #ccc;
display:block;
width:100%;
height:60px;
margin:6px 0px;
}
button, #ws {
font-size: 12 pt;
padding: 4px 6px;
border-radius: 5px;
border: 1px solid #bbb;
background-color: #eee;
}
code, pre, #ws, #message {
font-family: Monaco;
font-size: 10pt;
border-radius: 3px;
background-color: #F8F8F8;
color: inherit;
}
code {
border: 1px solid #EAEAEA;
margin: 0 2px;
padding: 0 5px;
}
pre {
border: 1px solid #CCCCCC;
overflow: auto;
padding: 4px 8px;
}
pre > code {
border: 0;
margin: 0;
padding: 0;
}
#ws { background-color: #f8f8f8; }
table {
border-collapse: collapse;
font-family: Helvetica, arial, freesans, clean, sans-serif;
color: rgb(51, 51, 51);
font-size: 15px; line-height: 25px;
padding: 0; }
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
table tr:nth-child(2n) {
background-color: #f8f8f8; }
table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }
table tr th :first-child, table tr td :first-child {
margin-top: 0; }
table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></p><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <div id="bloop_sign_1404076729967804928" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">Arun</div></div> <div style="color:black"><br>From: <span style="color:black">Gabor Grothendieck</span> <a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a><br>Reply: <span style="color:black">Gabor Grothendieck</span> <a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a><br>Date: <span style="color:black">June 29, 2014 at 10:59:22 PM</span><br>To: <span style="color:black">datatable-help@lists.r-forge.r-project.org</span> <a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>Subject: <span style="color:black"> [datatable-help] by row <br></span></div><br> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>There was some discussion of an .EACHI facility for data.table. Not
<br>sure what happened about that but I have an example that might be
<br>useful:
<br>
<br>http://stackoverflow.com/questions/24472254/splitting-a-column-by-factor-within-a-data-frame/24472571#24472571
<br>
<br>which shows the code where DT has columns v1, v2 and v3:
<br>
<br>DT[, split(v2, v1), by = names(DT)]
<br>
<br>It works well if the rows of DT are unique but if they are not then
<br>one must do something ugly like appending a uniquifying column of
<br>1:nrow(DT), say, and then including that in by and then finally
<br>removing it again at the end.
<br>
<br>This suggests two features:
<br>
<br>1. The ability to tell it to do the by by row
<br>2. The ability to selectively omit by variables from the output
<br>
<br>For example, if one could use a pseudo column .I and if -.I meant do
<br>not include it in the output then one could write:
<br>
<br>DT[, split(v2, v1), by = c(names(DT), -.I)]
<br>
<br>Other syntaxes may be thought of too and the main suggestion here is
<br>the possible need for these features rather than the specific syntax.
<br>
<br>(By the way, is there an intention to move to the issue system on
<br>github for things like this?)
<br>
<br>--
<br>Statistics & Software Consulting
<br>GKX Group, GKX Associates Inc.
<br>tel: 1-877-GKX-GROUP
<br>email: ggrothendieck at gmail.com
<br>_______________________________________________
<br>datatable-help mailing list
<br>datatable-help@lists.r-forge.r-project.org
<br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
<br></div></div></span></blockquote><p></p></body></html>