[R] Help with sub-setting

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Tue May 26 01:13:26 CEST 2020


oops, that should have been:

by(data$Z,data[,c("X","Y")],summary)

Jim

On Tue, May 26, 2020 at 9:00 AM Jim Lemon <drjimlemon using gmail.com> wrote:
>
> Hi Jamie,
> Your seem to want some descriptive statistic applied to subsets of
> your data frame "data" (maybe a more imaginative name would help).
> I'll guess that your data frame contains variables X, Y and Z among
> others. Further, I'll guess that you want the summaries of variable Z
> subset by Y and X.
>
> data<-data.frame(X=sample(1:2,100,TRUE),Y=sample(1:2,100,TRUE),
>  Z=rnorm(100))
> by(data,data[,c("X","Y")],summary)
>
> Jim
>
> On Tue, May 26, 2020 at 2:57 AM Burgess, Jamie
> <Jamie.Burgess using liverpool.ac.uk> wrote:
> >
> > Dear all,
> >
> > I hope this message finds you well. I am currently trying to subset my data by two variables, so far, I have tried two different ways to stratify participants into groups. I would like to use the ‘summary’ and ‘table’ arguments to characterise the data of participants based on the presence of two variables and summarise this sub-set against a third variable.
> > I have used this method:
> >
> > dgb001<-subset(data,data$variable==1 & data,data$variable)
> >
> >
> > However, I get the following error: “Error: cannot allocate vector of size 16.0 Gb”. Is there another method I can try?
> >
> >
> > Kind regards,
> >
> >
> > Jamie Burgess
> >
> > PhD Student Endocrinology and Diabetes
> >
> > University of Liverpool
> >
> > Aintree University Hospital &
> >
> > The Walton Centre
> >
> > Institute of Ageing & Chronic Disease
> >
> > 0151 529 5936
> >
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help using 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.



More information about the R-help mailing list