I am receiving a replacement error for my loop using tigris function in R

ok,

Print i inside your loop and show us rows around the position of i you have the error.

You can try also a minimal reprex data. see this :

Best Practices: how to prepare your own data for use in a reprex if you can’t, or don’t know how to reproduce a problem with a built-in dataset?