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

2014-12-30 Thread Berend Hasselman
> On 31-12-2014, at 08:40, Karim Mezhoud wrote: > > 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.

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

2014-12-30 Thread Karim Mezhoud
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 Ô