79595813

Date: 2025-04-28 04:44:54
Score: 0.5
Natty:
Report link

Why is it iterating without me specifying a for-loop or any flow control like that?

Actually, there is no iterating going on here. You are using vectorized functions (functions that accept a vector and return a vector), here specifically you are using is.na() and [, which means that you don't need to use for loops or other control-flow methods. Vectorization means that operations are performed in parallel, not one by one on each element.

There's a lot more to vectorization in R, but these SO links can give you a lot more reading:

How to define a vectorized function in R

How do I know a function or an operation in R is vectorized?

Reasons:
  • Blacklisted phrase (1): How do I
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): Why is it it
  • High reputation (-2):
Posted by: Edward