dplyr Update a cell in a data.frame
问题 df <-data.frame(x=c(1:5),y=c(letters[1:5])) Let's say I want to modify the last row, update.row<-filter(df,x==5) %>% mutate(y="R") How do I update this row into the data.frame ? The only way, I found albeit a strange way is to do an anti-join and append the results. df <-anti_join(df,update.row,by="x") %>% bind_rows(update.row) However, it seems like a very inelegant way to achieve a simple task. Any ideas are much appreciated... 回答1: If you are insistant on dplyr , perhaps df <-data.frame(x