<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks Steve,<br>
<br>
Though it is slower yes, it corresponds to what I was looking for. I
don't work with a very large amount of data, so the second option is
appropriate for me, at least at this stage.<br>
Thanks a lot again,<br>
<br>
Regards,<br>
Emmanuel<br>
<br>
Le 21/07/2011 15:15, Steve Lianoglou a écrit :
<blockquote
cite="mid:CAHA9McOCb_Z4ato_qZ5hfkf+2rjQ0RTmMTEyOJ32EvSv0Upm2Q@mail.gmail.com"
type="cite">
<pre wrap="">Hi,
On Thu, Jul 21, 2011 at 3:27 AM, Emmanuel Blondel
<a class="moz-txt-link-rfc2396E" href="mailto:emmanuel.blondel1@gmail.com"><emmanuel.blondel1@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Dear all,
I have a datatable (mydt) with a reference column (code) for which I set a
key, and a set of numeric columns (A ,B, C, D, E).
I obtain this from a serie of script codes, but the issue is that I have
duplicated rows (code), So i want to do is according to codestation, for
each of the columns..
I could do the following code for one single column:
result<-mydt[,sum(A),by=code]
but I would like to know if it is possible to do it for each of the columns,
so I get a databable with the same columns with sum value, group by
codestation. Do you have any suggestion?
</pre>
</blockquote>
<pre wrap="">
Do you mean something like:
R> mydt[, list(A=sum(A), B=sum(B), C=sum(C), D=sum(D), E=sum(E)), by=code]
or equivalently, but maybe slower (there is a recent thread on the
list about this):
R> mydt[, lapply(.SD, sum), by=code]
Is that what you are after?
-steve
</pre>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<b>Emmanuel Blondel</b><br>
GIS Consultant<br>
<br>
Geographic Information Systems<br>
in Agronomy - Environment -Fisheries<br>
Email: <a class="moz-txt-link-abbreviated" href="mailto:emmanuel.blondel1@gmail.com">emmanuel.blondel1@gmail.com</a> - <a class="moz-txt-link-abbreviated" href="mailto:Emmanuel.Blondel@fao.org">Emmanuel.Blondel@fao.org</a><br>
Phone: +33 (0) 6 45 97 87 52 <br>
</div>
</body>
</html>