[R] [External] Help with sub-setting

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Mon May 25 19:36:18 CEST 2020


Yes. In particular:

data$variable==1 & data

makes no sense (data is a data frame). A typo perhaps? Or as Richard
indicated, consult references/tutorials to learn proper syntax for
(vectorized) predicates.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Mon, May 25, 2020 at 10:20 AM Richard M. Heiberger <rmh using temple.edu>
wrote:

> I think the syntax you are looking for is
>
> datasubset <- data[ data$A ==1 & data$B ==  1 , ] )
>
> This gives the subset of your original data for variable A with value
> 1 and variable B with value 1.
>
>
> On Mon, May 25, 2020 at 12:57 PM 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.
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list