On Sun, 20 Mar 2016 22:55:33 -0700, carlsutton wrote: > My goal is to create proportions for several variables, by group, and > save these in new columns. So far I have spent most of the day > researching this, retaking the Data Camp data table course, and all > iterations have failed miserably. Several google searches were not > helpful. Console out put (code and error messages below. Hopefully. > Proportions.R > <http://r.789695.n4.nabble.com/file/n4718825/Proportions.R> > <http://r.789695.n4.nabble.com/file/n4718825/Capture.png> > > Carl Sutton > > > > ----- > Carl Sutton
Try this: dt1[, ':='(propta = sum(a)/.N, propt.b = sum(b)/.N), by = c] _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
