Re: [datatable-help] Create matrix of columns from grouped rows

2016-11-23 Thread Eric Archer
Thanks! That's about 2-3x faster. I wasn't familiar with stack/unstack. Now
I have another tool.

Cheers,
e.




*Eric Archer, Ph.D.*

Southwest Fisheries Science Center (NMFS/NOAA)
8901 La Jolla Shores Drive
La Jolla, CA 92037 USA
858-546-7121 (work)
858-546-7003 (FAX)

Marine Mammal Genetics Group: swfsc.noaa.gov/mmtd-mmgenetics
GitHub: github/ericarcher

&

Adjunct Professor, Marine Biology
Scripps Institution of Oceanography
University of California, San Diego
http://profiles.ucsd.edu/frederick.archer


"


*The universe doesn't care what you believe. The wonderful thing about
science is that it   doesn't ask for your faith, it just asks   for your
eyes.*"  - Randall Munroe

"*Lighthouses are more helpful than churches.*"
   - Benjamin Franklin

   "*...but I'll take a GPS over either one.*"
   - John C. "Craig" George

On Wed, Nov 23, 2016 at 11:11 AM, nachti [via R] <
ml-node+s789695n472677...@n4.nabble.com> wrote:

> Try this:
>
> t1 <- dt[, unlist(.SD), by = id]
> t(unstack(t1, form = V1 ~ id))
>
> (I think you get done with the colnames yourself ...)
>
> Cheers,
> ~g
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/Create-matrix-of-columns-from-grouped-rows-
> tp4726777p4726778.html
> To unsubscribe from Create matrix of columns from grouped rows, click here
> 
> .
> NAML
> 
>




--
View this message in context: 
http://r.789695.n4.nabble.com/Create-matrix-of-columns-from-grouped-rows-tp4726777p4726779.html
Sent from the datatable-help mailing list archive at Nabble.com.___
datatable-help mailing list
datatable-help@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Re: [datatable-help] Create matrix of columns from grouped rows

2016-11-23 Thread nachti
Try this:

t1 <- dt[, unlist(.SD), by = id]
t(unstack(t1, form = V1 ~ id))

(I think you get done with the colnames yourself ...)

Cheers,
~g



--
View this message in context: 
http://r.789695.n4.nabble.com/Create-matrix-of-columns-from-grouped-rows-tp4726777p4726778.html
Sent from the datatable-help mailing list archive at Nabble.com.
___
datatable-help mailing list
datatable-help@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help