Skip to content
Back to formatted view

Raw Message

Message-ID: <A4BDB3E1-ACAD-4A67-939F-690BCF9E8ABC@me.com>
Date: 2013-02-16T19:17:48Z
From: Marc Schwartz
Subject: Extracting Numeric Columns from Data Fram
In-Reply-To: <1361038535.41276.YahooMailNeo@web163005.mail.bf1.yahoo.com>

On Feb 16, 2013, at 12:15 PM, Barry DeCicco <bdecicco2001 at yahoo.com> wrote:

> Hello,
> 
> I've got a data frame with a mix of numeric, integer and factor columns.
> I'd like to pull out (or just operate only on) the numeric/integer columns.
> Every thing I've found in searches is about how to subset by rows,
> or how to operate assuming you have the column names.  I'd like to pull
> by type.
> 
> Thanks!
> 
> Barry


Something like the following should work. If your data frame is "DF":

  NewDF <- DF[, sapply(DF, is.numeric)]

Regards,

Marc Schwartz