R works on whole vectors at once. A loop that walks through rows one by one, especially one that grows a result with c(), is slower and longer than the vectorized version, and it hides the intent.
revenue <- c()
for (i in seq_len(nrow(orders))) {
revenue <- c(revenue, orders$units[i] * orders$unit_price[i])
}
is orders$units * orders$unit_price. Most loops map onto a vectorized tool: arithmetic for row-by-row math, if_else() or case_when() for an if inside the loop, cut() for bands, cumsum() for a running total, and match() or a join for looking values up in another table.
cut() needs care at the edges: by default each band includes its upper limit, so with breaks at 8 and 24, a value of exactly 8 falls in the first band. right = FALSE moves it up a band. Loops still have their place for steps that depend on the previous result in complicated ways; they just aren't the first tool.
Arithmetic, a condition, bands (9 falls in the first) and a running total, with no loop.