[R] Split

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon Dec 23 18:44:07 CET 2019


On Mon, 23 Dec 2019 17:56:35 +0300
Medic <mailiPadpost using gmail.com> wrote:

> I would like to split
> mydata$var
> by
> mydata$group #to get var1 and var2

There is the split() function that does exactly that (except it returns
a list instead of multiple variables)...

> And then get
> summary (var1, var2)  #this is my finite aim

...and you can either use lapply() on the list returned by split() or
tapply() to both split the dataset into groups and call summary() on
each in one expression. See ?tapply and example(tapply) for more info.

-- 
Best regards,
Ivan



More information about the R-help mailing list