Does anyone knows why this is producing an error like this (Error in { :
task 1 failed - "arguments imply differing number of rows: 1, 0")?
I tried to run a loop through large data to predict one unique row from the dataset using ranger package. Is the problem because rows don't have a similar length or something else?
Thanks
Using the foreach makes debugging more difficult. Try replacing the foreach with a simple for-loop instead and see at which iteration the error occurs (by printing the iteration at the start of each for-loop).
Then execute the inside of the for-loop line by line for that iteration, and see where it generated the error. This error is usually thrown when creating data frames goes wrong and some variables have x results and others have y, not matching up when combined...
The suggestion to use a for loop, rather than using foreach() is a good suggestion. The ranger() function is already parallelized implementation of RF, so trying to run it in parallel is probably not going to speed things up unless you are running on a cluster of multicore machines.
You don't need to print anything, as if the loop brokes, you'll get the offending iterator from 'i', as it will have the last value before the loop goes wrong.