If I understand correctly you need summary by group. I would suggest arsenal package and tableby
tab1 <- tableby(group ~ anova(var, "meansd", digits=1) + #mean and sd + round to 1 digit + anova kwt(var, "medianq1q3", digits=1) , #median q1 and q3 + round to 1 digit + Kruskal-Wallis data=sn.l.v2.t0) summary(tab1,text=TRUE) #output as txt to console write2word(tab1,"tab1.docx", pfootnote=TRUE) #save as formatted word table or even simpler using Rcmdr - Statistics - Numerical summaries and tha choose summarize by groups Milos On Mon, 23 Dec 2019 at 15:57, Medic <mailipadp...@gmail.com> wrote: > I have > mydata$var > > and I have > mydata$group #two group > > I would like to split > mydata$var > by > mydata$group #to get var1 and var2 > > And then get > summary (var1, var2) #this is my finite aim > > How to encode it all? > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.