dplyr
dplyr

Reputation: 93

How to change row names of a particular column in the same way in R

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!

Upvotes: 0

Views: 313

Answers (1)

Jilber Urbina
Jilber Urbina

Reputation: 61214

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

Upvotes: 1

Related Questions