Update a Value in One Column Based on Criteria in Other Columns

前端 未结 4 704
遥遥无期
遥遥无期 2020-11-29 05:28

If my data frame (df) looks like this:

Name        State
John Smith  MI
John Smith  WI
Jeff Smith  WI

I want to rename the John Smith from

4条回答
  •  渐次进展
    2020-11-29 05:57

    You can also use package data.table:

    library(data.table)
    setDT(df)[State=="WI", Name:=paste0(Name,"1")]
    

提交回复
热议问题