  Since a data.frame is a list, you should use lapply() or sapply():

 > df <- data.frame(a=1:5, b=LETTERS[1:5])
 > lapply(df, class)
$a
[1] "integer"
$b
[1] "factor"
 > sapply(df, class)
         a         b
"integer"  "factor"

HTH,
Ivan

Le 8/26/2010 17:31, Daniel Brewer a écrit :
> Hello,
>
> Is there a simple way to get the class type for each column of a
> data.frame?  I am in the situation where I would like to get all the
> columns of a data.frame that are factors.
>
> I have tried:
> apply(df,2,class)
> but all the columns come back as class "character".
>
> Thanks
>
> Dan
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231




	[[alternative HTML version deleted]]

