switching from for loop to dplyr for predictions