Replacing data values based on grep result in R

后端 未结 2 1448
予麋鹿
予麋鹿 2021-01-05 18:56

I have a data frame. One of the columns has values like:

WIND
WINDS
HIGH WIND
etc

among the other values. Now

2条回答
  •  清酒与你
    2021-01-05 19:10

    You can just subset the original column for these values by using grepl and replace

    df$col1[grepl("WIND",df$col1)]<-"WIND"
    

提交回复
热议问题