[R] select only the numeric variables

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Thu Oct 20 20:25:13 CEST 2005



lamack lamack wrote:
> Dear all, how can I select only the numeric (or character) variables from a
> date.frame?
> 
> Best regards
> 

Try:

x[sapply(x, is.numeric)]

x[sapply(x, is.character)]

where `x' is your data.frame.

--sundar




More information about the R-help mailing list