This should work without a for
loop.
df <- data.frame(data = c(1, 2, 3, 4, 5, 6),
scores = c(76, 90, 52, 65, 90, 90))
df
# data scores
# 1 1 76
# 2 2 90
# 3 3 52
# 4 4 65
# 5 5 90
# 6 6 90
# Setup and change specific rows
rows_to_change <- c(2, 4, 5)
df[rows_to_change, 2] <- 101 - df[rows_to_change, 2]
df
# data scores
# 1 1 76
# 2 2 11
# 3 3 52
# 4 4 36
# 5 5 11
# 6 6 90
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…