[BioC] Basic R question

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Jul 14 17:23:30 CEST 2011

Since we're playing code golf, just wanted to point out:

On Thu, Jul 14, 2011 at 10:44 AM, Brian Herb <brianherb at jhmi.edu> wrote:
> Nathalie-
> try-
> chr1=subset(object,object$chrom==1)
> where object is your dataframe

The cool thing about subset is that the column names of the data.frame
you are working with are "injected" into the scope of the expression
you are using a logical subset, so instead of:

chr1 <- subset(object, object$chrom == 1)

You can do

chr1 <- subset(object, chrom == 1)

Ain't that something?


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the Bioconductor mailing list