Message-ID: <1346161052.90261.YahooMailNeo@web142603.mail.bf1.yahoo.com>
Date: 2012-08-28T13:37:32Z
From: arun
Subject: find and replace
In-Reply-To: <1346111235.23239.YahooMailNeo@web125201.mail.ne1.yahoo.com>
Hi,
Try this:
dat1<-readLines(textConnection(
?"ID Name Fav_Place
?101 Andrew? Phoenix,AZ
?201 John SanFrancisco
?303 Julie California/New York
?304 Monica? New York"))
?gsub("Phoenix","Tucson",gsub("New York","New York City",dat1))
#[1] "ID Name Fav_Place"????????????????? "101 Andrew? Tucson,AZ"????????????
#[3] "201 John SanFrancisco"????????????? "303 Julie California/New York City"
#[5] "304 Monica? New York City"
A.K.
----- Original Message -----
From: Sapana Lohani <lohani.sapana at ymail.com>
To: R help <r-help at r-project.org>
Cc:
Sent: Monday, August 27, 2012 7:47 PM
Subject: [R] find and replace
Hi,
My data frame (Students) is
ID Name Fav_Place
101 Andrew? Phoenix AZ
201 John San Francisco
303 JulieCalifornia / New York
304 Monica? New York
How can I replace Phoenix with Tucson & New York with New York City in the df?
Thanks
??? [[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.