On Thu, Aug 26, 2010 at 4:44 PM, Marc Schwartz <marc_schwa...@me.com> wrote:
>> sapply(iris, class) > Sepal.Length Sepal.Width Petal.Length Petal.Width Species > "numeric" "numeric" "numeric" "numeric" "factor" Note that comparing the result of class(foo) is a bad way of telling if something is of a particular class, because of inheritance - class(foo) can be a vector if the object belongs to more than one class. Always test using is.whatever(foo), which returns TRUE if foo is a whatever: > f=factor(letters) > class(f) [1] "factor" > class(f)=c("factor","alphabet") > f [1] a b c d e f g h i j k l m n o p q r s t u v w x y z Levels: a b c d e f g h i j k l m n o p q r s t u v w x y z > is.factor(f) [1] TRUE but now: > class(f)=="factor" [1] TRUE FALSE Barry ______________________________________________ R-help@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.