s-news
[Top] [All Lists]

Re: a simple question--How to select subset of Dataframe in S-Plus

To: "Liu Zhigang" <email.lzg@gmail.com>
Subject: Re: a simple question--How to select subset of Dataframe in S-Plus
From: "Thompson, David (MNR)" <david.thompson@mnr.gov.on.ca>
Date: Mon, 29 May 2006 09:14:59 -0400
Cc: "s-news" <s-news@lists.biostat.wustl.edu>
Thread-index: AcaDIeGrsucjGXEiRrKgYO2s8G5v8A==
Thread-topic: a simple question--How to select subset of Dataframe in S-Plus
Liu,

With data.frame named 'df' and columns named 'x' and 'y' use
df[df$x>0 & df$y<0, ] to select all columns with rows having
specified conditions.

DaveT.
**********************************************************
Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
Sault Ste. Marie, Ontario, Canada
david.thompson@mnr.gov.on.ca
**********************************************************

-----Original Message-----
From: Liu Zhigang [mailto:email.lzg@gmail.com] 
Sent: May 29, 2006 5:36 AM
To: s-news@lists.biostat.wustl.edu
Subject: a simple question--How to select subset of Dataframe in S-Plus


In SAS, I can use " if " to select my wanted observations.
For example, I want to select the obs satisfy the condition of  x>0 and
y<0  (where x and y are variable in a dataset. ) 
and  operate  with   this subset.In SAS I can do if use following
command:

[ If x>0 and y<0;  ]

But who can tell me how to make this select in S_Plus.

Thank you!

Liu zhigang 
Jilin University 

<Prev in Thread] Current Thread [Next in Thread>