Filter parameters, run a function on the filtered parameters, and looping

R has for, but it's not often the preferred approach. For an example see this recent post. Come back with a reprex (see the FAQ) if help is needed.