user3188390
user3188390

Reputation: 613

How to replace a string with another string in a column in R?

I have a csv file like

Data.csv

Id,Name,City
23,radu,Los Angeles
34,tree,Chicago
rtet,great,Miami
rtet,francis,Paris

where

  record <- read.csv("Data.csv",header=TRUE);
  Identity <- record$Id

I used

  gsub("rtet","67",Identity)

But it does not work.

How to replace "rtet" in the csv file with "67" in R? New to R.Any help is appreciated.

Upvotes: 1

Views: 1501

Answers (1)

Troy
Troy

Reputation: 8691

record$Id<-gsub("rtet","67",record$Id)

works for me...

Upvotes: 2

Related Questions