s-news
[Top] [All Lists]

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

To: Jonathan Dakin <jdakin@overwey.demon.co.uk>
Subject: Re: a simple question--How to select subset of Dataframe in S-Plus
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Mon, 29 May 2006 06:58:46 -0500
Cc: "'Liu Zhigang'" <email.lzg@gmail.com>, s-news@lists.biostat.wustl.edu
In-reply-to: <000001c68315$f8fbc800$1afea8c0@jdakin>
Organization: PDF Solutions, Inc.
References: <000001c68315$f8fbc800$1afea8c0@jdakin>
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
I think you mean:

dataset[dataset$x > 0 & dataset$y < 0, ]

presuming "x" and "y" are columns in "dataset".

--sundar

Jonathan Dakin wrote:
dataset[x > 0 & y <0,]
selects all rows of the dataframe which satisfy. Jonathan Dakin

    -----Original Message-----
    *From:* s-news-owner@lists.biostat.wustl.edu
    [mailto:s-news-owner@lists.biostat.wustl.edu] *On Behalf Of *Liu Zhigang
    *Sent:* 29 May 2006 10:36
    *To:* s-news@lists.biostat.wustl.edu
    *Subject:* [S] 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>