[R] appending to a vector

dirknbr dirknbr at gmail.com
Thu Apr 14 10:59:04 CEST 2011


Which one is more efficient?

x2=c()
for (i in 1:length(x)) {
 x2=c(x2,func(x[i]))
}

or 

x2=x
for (i in 1:length(x)) {
 x2=func(x[i])
}

where func is any function?

Dirk 

--
View this message in context: http://r.789695.n4.nabble.com/appending-to-a-vector-tp3449109p3449109.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list