[R] Stichprobe bilden

Jonathan Baron baron at psych.upenn.edu
Sun Apr 25 13:23:20 CEST 2004


On 04/25/04 12:27, sebastian.goeres at student.unisg.ch wrote:
>Liebe Alle,
>
>ich habe ien Problemm. ich habe einen Panel-Datensatz ueber die 185
>Staaten (nach Code von IMF) und von 1948-1999. Ich habe auch 12 Variablen
>in diesem Datensatz, die ich fuer die Regression benoetige. ich muss ein
>sub-sample bilden fuer die 65 Staaten und fuer den 1970-1999 Jahren. Wie
>kann ich aus dieser Stichprobe eine kleienere Stichprobe mit R bilden,
>damit auch meine 12 Variablen in Bezug auf die Jahren und Laendern richtig
>selektiert wurden.

My German is good enough to understand what you wrote, but not
good enough to write back.

You do not say enough.  The simple answer is to use the subset
operator [], or subset(), and something else like %in% to match
the countries.

For example, if your data are in a data frame called Gross, which
has a variable for Staat and another for Jahr,

Klein <- Gross[(Gross$Jahr > 1969) & (Gross$Staat %in% Staat65),]

where Staat65 is a vector with the list of countries you want,
like

Staat65 <- c("Germany","China", .....)

Jon
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page:            http://www.sas.upenn.edu/~baron
R page:               http://finzi.psych.upenn.edu/




More information about the R-help mailing list