[R] which is faster "for" or "apply"

Karim Mezhoud kmezhoud at gmail.com
Wed Dec 31 08:40:01 CET 2014


Hi All,
I would like to choice between these two data frame convert. which is
faster?

   for(i in 1:ncol(DataFrame)){

                    DataFrame[,i] <- as.numeric(DataFrame[,i])
                }


OR

DataFrame <- as.data.frame(apply(DataFrame,2 ,function(x) as.numeric(x)))


Thanks
Karim
  Ô__
 c/ /'_;~~~~kmezhoud
(*) \(*)   ⴽⴰⵔⵉⵎ  ⵎⴻⵣⵀⵓⴷ
http://bioinformatics.tn/

	[[alternative HTML version deleted]]



More information about the R-help mailing list