Re: [R] how can I delete rows?

From: Philipp Pagel <philipp.pagel.lists_at_t-online.de>
Date: Wed 19 Jul 2006 - 18:01:16 EST

On Tue, Jul 18, 2006 at 12:25:47PM -0300, raul sanchez wrote:
> I have the Barro-Lee data set which contains 98 countries and I want
> to run the regressions only for the Latin America countries, so what
> do you recomend? How can I delete all the other countries or how can

> I select the countries of Lat. Am. thank you

> this is the list of countries
> SHCODE COUNTRY NAME WBCTRY (1) (2)
> _________________________________________________________________
>
> 1 Algeria DZA + +
> 2 Angola AGO - -
> 3 Benin BEN - +
> 4 Botswana BWA + +
> 5 Burkina Faso HVO - -
> 6 Burundi BDI + -
> 7 Cameroon CMR + +
[...]

Assuming the data is stored in a data frame called bl you could do something like this:

First you generate a list of all countries you are interested in - e.g.

> set = c('Benin', 'Congo', 'Mali')

And then you subset the data frame with it

> bl[bl$COUNTRY %in% set, ]

   SHCODE COUNTRY NAME WBCTRY X.1. X.2.

3       3   Benin  BEN      -    +   NA
12     12   Congo  COG      -    +   NA
26     26    Mali  MLI      -    +   NA


cu
	Philipp

-- 
Dr. Philipp Pagel                            Tel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics      Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS          Tel.  +49-89-3187 3675
GSF - National Research Center               Fax.  +49-89-3187 3585
      for Environment and Health

Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

R-help@stat.math.ethz.ch mailing list
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. Received on Wed Jul 19 18:03:27 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 19 Jul 2006 - 20:18:00 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.