Skip to content

select only the numeric variables

3 messages · lamack lamack, Sundar Dorai-Raj, Chuck Cleland

#
Dear all, how can I select only the numeric (or character) variables from a
date.frame?

Best regards
#
lamack lamack wrote:
Try:

x[sapply(x, is.numeric)]

x[sapply(x, is.character)]

where `x' is your data.frame.

--sundar
#
library(MASS)
anorexia[,sapply(anorexia, is.numeric)]
lamack lamack wrote: