[R] Extracting Numeric Columns from Data Fram

Rui Barradas ruipbarradas at sapo.pt
Sat Feb 16 20:11:12 CET 2013


Hello,

You should provide us with a data example, like the posting guide says.
Anyway, see the following example.

# make up some data
dat <- data.frame(X = 1:4, Y = rnorm(4), Z = letters[1:4])
str(dat)
# this returns the numeric/integer columns
dat[sapply(dat, is.numeric)]


Hope this helps,

Rui Barradas

Em 16-02-2013 18:15, Barry DeCicco escreveu:
> 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
>
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list