R: [R] retrieve rows from frame assuming criterion [corrected]

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jul 23 16:29:39 CEST 2004


On Fri, 23 Jul 2004, Guazzetti Stefano wrote:

> sorry for my previus (WRONG)
> answer, as someone already pointed out
> a solution could be
> 
> subset(data, PUNTAR==c("IX49","IX48"))

That's still wrong.  You want PUNTAR %in% c("IX49","IX48").  Using ==
recycles entries, so it tests the first element against "IX49", the second
against "IX48", the third against "IX49" ....

> > -----Messaggio originale-----
> > Da: Guazzetti Stefano 
> > Inviato: venerdì 23 luglio 2004 15.55
> > A: 'Luis Rideau Cruz'; r-help at stat.math.ethz.ch
> > Oggetto: R: [R] retrieve rows from frame assuming criterion
> > 
> > 
> > Assuming your data.frame is called "data"
> > 
> > data[data$PUNTAR==c("IX49","IX48"),]
> > 
> > is probably what you want
> > 
> > Stefano

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list