Home > Software engineering >  How to change row names of a particular column in the same way in R
How to change row names of a particular column in the same way in R

Time:11-09

I am new in R and I have a very basic question.

MY ID column in my data frame is like this:

ID 
100-01
101-01
500-01
499-01 
.
.

And I want to convert those "-01" to "-02". How can I do that?

Thanks a lot!

CodePudding user response:

You can use sub

  df$ID <- sub("-01", "-02", df$ID)
  df
      ID
1 100-02
2 101-02
3 500-02
4 499-02
  •  Tags:  
  • r
  • Related