r return index of rows that have NA in dataframe

# Sample dataframe
df <- data.frame(
  A = c(1, 2, NA, 4),
  B = c(NA, 2, 3, 4),
  C = c(1, 2, 3, 4)
)

# Return indices of rows with NA values
rows_with_na <- which(apply(is.na(df), 1, any))