| To: | s-news@lists.biostat.wustl.edu |
|---|---|
| Subject: | subsetting a dataframe |
| From: | "Data Analytics Corp." <dataanalytics@earthlink.net> |
| Date: | Sun, 24 Feb 2008 21:11:35 -0500 |
| Domainkey-signature: | a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=earthlink.net; b=sZlkTKoVlaHvS0JtdZwEgjbkfiYzpvvDH7D7Jcvday2Y598Z01dJLy0jtGdhMWht; h=Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding:X-ELNK-Trace:X-Originating-IP; |
| User-agent: | Thunderbird 2.0.0.9 (Windows/20071031) |
Hi,I wrote a function, say foo, part of which subsets a dataframe. Let's say the dataframe is df with columns x y z 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 and I want the subset such that x == 1. I normally just use df[df$x == 1, ]But what if I want to include the subsetting variable in an argument list so that I could switch between x, y and z depending on the problem? Let the argument be sub and the call be, say, foo(sub = "x") or foo(sub = "z"). I can't figure out what to write in place of df[df$x == 1,]. Does anyone know how to do this? Thanks, Walt Paczkowski |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | BRFSS & SPlus, jose Bartolomei |
|---|---|
| Next by Date: | subsetting question, Data Analytics Corp. |
| Previous by Thread: | BRFSS & SPlus, jose Bartolomei |
| Next by Thread: | subsetting question, Data Analytics Corp. |
| Indexes: | [Date] [Thread] [Top] [All Lists] |