Skip to content

[Bioc-devel] Applying "class" function to columns of a data.frame always return character

3 messages · João Daniel Nunes Duarte, Martin Morgan, Nicolas Delhomme

#
On 01/20/2012 07:07 AM, Jo?o Daniel Nunes Duarte wrote:
A data frame is a list of equal length vectors, so you can use

    sapply(df, class)
    class(df[["some_column"]]
    class(df$some_column)

Martin

  
    
#
This would work:

sapply(1:ncol(dataframe),function(i,df){
	is.factor(df[,i])
},dataframe)

Cheers,

---------------------------------------------------------------
Nicolas Delhomme

Genome Biology Computational Support

European Molecular Biology Laboratory

Tel: +49 6221 387 8310
Email: nicolas.delhomme at embl.de
Meyerhofstrasse 1 - Postfach 10.2209
69102 Heidelberg, Germany
---------------------------------------------------------------
On 20 Jan 2012, at 16:07, Jo?o Daniel Nunes Duarte wrote: