Re: [R] drop elements of vector by class

From: McGehee, Robert <>
Date: Sat 18 Jun 2005 - 01:30:48 EST

a <- data.frame(a = 1:2, b = c("a", "b"), c = I(c("a", "b")))

a <- a[ , !sapply(a, class) %in% "factor"]

-----Original Message-----
From: E. Michael Foster [] Sent: Friday, June 17, 2005 10:58 AM
Subject: [R] drop elements of vector by class

i'm trying to build a little summary table for the contents of a data frame.

t<-sapply(macro, data.class)
c<-sapply(macro, length)
m<-sapply(macro, mean, na.rm=T, digits=2)
cbind(type=t, n=c , mean=m)

I want to drop the variables that are factors so I can include -max- and

-min- in my table.
-macro- contacts the data--how do I drop the variables according to their

michael foster

E. Michael Foster
(W) 814-865-1923
(Fax) 814-863-0000

After 7/1

Professor of Maternal and Child Health
School of Public Health
University of North Carolina, Chapel Hill Rosenau Hall, CB# 7445
Chapel Hill, NC 27599-7445

309 Old Larkspur Way
Chapel Hill, NC 27516

UNC School of Public Health--voted #2 SPH by

. US News
. Association of Hand-to-Fin Carp Fisherman
. Iron Chef (not to be confused with the Iron Dukes!) mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Sat Jun 18 02:56:19 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:48 EST