Hi,
The "str_locate" function instringr package may do what you are looking for.
Hope this link will help...
http://en.wikibooks.org/wiki/R_Programming/Text_Processing
Taka
On Mon, Sep 19, 2011 at 7:15 PM, SNV Krishna wrote:
> Hi All,
>
> I have a character vector by name tickers
>
>> head(ti
rom: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Monday, September 19, 2011 10:10 PM
To: Sarah Goslee
Cc: SNV Krishna; r-help@r-project.org
Subject: Re: [R] text matching
On Sep 19, 2011, at 7:05 AM, Sarah Goslee wrote:
> Hi,
>
> On Mon, Sep 19, 2011 at 6:15 AM, SNV Krishna
>
On Sep 19, 2011, at 7:05 AM, Sarah Goslee wrote:
Hi,
On Mon, Sep 19, 2011 at 6:15 AM, SNV Krishna
wrote:
Hi All,
I have a character vector by name tickers
head(tickers,10)
V1
1 ADARSHPL.BO
2AGR.V
3 AGU
4 AGU.TO
5 AIMCO.BO
6 ALUFLUOR.BO
7
Hi,
On Mon, Sep 19, 2011 at 6:15 AM, SNV Krishna wrote:
> Hi All,
>
> I have a character vector by name tickers
>
>> head(tickers,10)
>
> V1
> 1 ADARSHPL.BO
> 2 AGR.V
> 3 AGU
> 4 AGU.TO
> 5 AIMCO.BO
> 6 ALUFLUOR.BO
> 7 AMZ.V
> 8 AVD
> 9 ANIL
Stephan Kolassa wrote:
> Hi Simeon,
>
> I played around a little with Vectorize and mapply, but I couldn't
> make it work :-( So, my best guess would be a simple loop like this:
>
> result <- as.character(paste(letters,colours(),"stuff",LETTERS))
> target <- c("red","blue","green","gray")
> for ( n
yet another attempt,
colours <- as.character(paste(letters,colours(),"stuff",LETTERS))
target <- c("red","blue","green","gray")
matches <- melt(sapply(target, grep, x=colours))
colours[matches$value] <- matches$L1
(probably a worse idea than a straight for loop, though)
baptiste
On 2
Jim/Stephan - absolutely perfect. thank you.
very grateful for your help.
simeon
On Sat, Mar 28, 2009 at 5:27 PM, jim holtman wrote:
> Does this do what you want:
>
> > x <- c('xxxredxxx', 'blue', 'xx', 'greenbluered')
> > pat <- 'red|green|blue'
> > result <- sub(paste("^.*?(",
Does this do what you want:
> x <- c('xxxredxxx', 'blue', 'xx', 'greenbluered')
> pat <- 'red|green|blue'
> result <- sub(paste("^.*?(", pat, ").*", sep=""), "\\1", x)
> # check if no match in original string; replace with 'other'
> match <- grep(pat, x)
> result[-match] <- 'other'
> r
Hi Simeon,
I played around a little with Vectorize and mapply, but I couldn't make
it work :-( So, my best guess would be a simple loop like this:
result <- as.character(paste(letters,colours(),"stuff",LETTERS))
target <- c("red","blue","green","gray")
for ( new.color in target ) { result[grep
Hi Simeon,
I'm slightly unclear on what exactly you are trying to achieve... Are
you trying to replace every entry of colours which *contains* "red" by
"red", dropping the rest of the entry? And same with "blue"?
A short example "before & after" would be helpful...
Best,
Stephan
simeon duc
thanks stephan. i'd been trying to make gsub work, but couldnt make it
replace the whole expression. so i'd resorted to trying to loop with grep -
but with two problems. firstly, i cant seem to make the loop 'remember'
the substitutions it makes (see below). secondly, it feels like this is a
r
Hi Simeon,
?gsub
HTH,
Stephan
simeon duckworth schrieb:
I am trying to simplify a text variable by matching and replacing it with a
string in another vector
so for example in
colours <- paste(letters,colours(),"stuff",LETTERS)
find and replace with ("red","blue","green","gray","yellow","othe
12 matches
Mail list logo