[R] Deleting a particular row

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Oct 5 20:15:41 CEST 2004


Sundar Dorai-Raj <sundar.dorai-raj at pdf.com> writes:

> S Peri wrote:
> 
> > Hi,
> >   I have a data frame. E.g:
> >              Fertility Agriculture
> > Courtelary        80.2        17.0
> > Delemont          83.1        45.1
> > Franches-Mnt      92.5        39.7
> > How can I delete :
> > Courtelary        80.2        17.0
> > Thanks.
> > P
> >
> 
> See ?subset. Assuming your data is called `mydata':
> 
> subset(mydata, Fertility != 80.2 | Agriculture != 17.0)
> 
> Note the single `|' for OR. See ?Logic for explanation.

subset(mydata, -1)  might be more to the point, or
subset(mydata, rownames(mydata) != "Courtelary") , or just
mydata[-1,] , or
mydata[-match("Courtelary",rownames(mydata))] ,
or....


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list