Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以,这就是我想做的事情:
df <- data.frame(a=1:6, b=1:6) ss <- magicSubset(df, a <= 3) ss$b <- 100 df$b # should be c(100,100,100,4,5,6)
R中或包中有类似的东西吗?我想实施起来不会太难......有什么理由这是一个坏主意吗?
您可以对其进行子集化df$b并为其分配一个值:
df$b
df$b[df$a <= 3] <- 100