API (rinat) with for-loop has error that breaks loop in R