我有vector index ,它对应于我想为一个特定列修改的df行
index <- c(1,3,6)
dm <- one two three four
x y z k
a b c r
s e t f
e d f a
a e d r
q t j i
现在我想修改第1,3和6行的“3”列,用“A”替换它中的任何值。
我应该使用 apply 吗?
答案 0 :(得分:1)
不需要apply
。您可以简单地使用以下内容:
dm$three[index] <- "A"