Re: [R] Vectorizing a for-loop for cross-validation in R

2019-01-23 Thread Aleksandre Gavashelishvili
Before posting on the r-help list I did run Rprof(). In my posting I asked for help with re-writing the specific script into sapply() or foreach()/doParallel format. Thanks anyway for your time and suggestions, Lexo On Thu, Jan 24, 2019 at 12:38 AM Eric Berger wrote: > Charles writes about savi

Re: [R] Vectorizing a for-loop for cross-validation in R

2019-01-23 Thread Eric Berger
Charles writes about saving execution time by eliminating redundancies. If you see redundancies related to calling a time-consuming function multiple times with the same arguments, a very easy way to speed up your program is to memoise the functions using the package memoise. HTH, Eric On Wed,

Re: [R] Vectorizing a for-loop for cross-validation in R

2019-01-23 Thread Berry, Charles
See inline. > On Jan 23, 2019, at 2:17 AM, Aleksandre Gavashelishvili > wrote: > > I'm trying to speed up a script that otherwise takes days to handle larger > data sets. So, is there a way to completely vectorize or paralellize the > following script: > >*# k-fold cross valida

[R] Vectorizing a for-loop for cross-validation in R

2019-01-23 Thread Aleksandre Gavashelishvili
I'm trying to speed up a script that otherwise takes days to handle larger data sets. So, is there a way to completely vectorize or paralellize the following script: *# k-fold cross validation* df <- trees # a data frame 'trees' from R. df <- df[sample(nrow(df)), ] # randomly shuf