I would read up on the 'gsub' command in R help. It does what you would like.
--
View this message in context:
http://r.789695.n4.nabble.com/R-newbie-how-to-replace-string-regular-expression-tp873169p3390170.html
Sent from the R help mailing list archive at Nabble.com
On Mon, Nov 3, 2008 at 3:36 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
I did provide a link to that solution already but also wanted to
show how to do it in the same way that the code in the question
was written.
Thanks for pointing me in right direction, both solutions are wonderful.
Yes
On Mon, Nov 3, 2008 at 11:51 AM, Krishna Dagli [EMAIL PROTECTED] wrote:
I have one doubt though, how does one locate packages that's
available for specific task (like this one). Does one look at package
index (http://cran.cnr.berkeley.edu/web/packages/index.html).
or is there any other trick?
On Mon, 3 Nov 2008, Krishna Dagli wrote:
On Mon, Nov 3, 2008 at 3:36 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
I did provide a link to that solution already but also wanted to
show how to do it in the same way that the code in the question
was written.
Thanks for pointing me in right
Hello;
I am a R newbie and would like to know correct and efficient method for
doing string replacement.
I have a large data set, where I want to replace character M, b,
and K (currency in Million, Billion and K) to millions. That is
209.7B with (209.7 * 10e6) and 100.00K with (100.00 *1/100)
Your gsub example is almost exactly what gsubfn in the gsubfn package
does. gsubfn like gsub except the replacement string is a function:
library(gsubfn)
gsubfn((.*)B$, ~ as.numeric(x) * 10e6, d, ignore.case = TRUE)
[1] 120.0M11.01m2.097e+09 100.00k 50
Also there are examples very
There was an error in your regexp which I did not correct. Here it is
again corrected to better illustrate the solution:
gsubfn((.*)B, ~ as.numeric(x) * 10e6, d, ignore.case = TRUE)
[1] 120.0M11.01m2.097e+09 100.00k 50
On Sun, Nov 2, 2008 at 7:55 AM, Gabor Grothendieck
[EMAIL
Gabor,
Why not just this:
expos - list( B=e9, M=e6, m=e6, k=e3 )
as.numeric( gsubfn([[:alpha:]], expos, d ) )
HTH,
Chuck
p.s. I am not sure why B goes with e6 or K with e-02 (below), but
Krishna can adjust the values accordingly.
On Sun, 2 Nov 2008, Gabor Grothendieck
I did provide a link to that solution already but also wanted to
show how to do it in the same way that the code in the question
was written.
On Sun, Nov 2, 2008 at 4:56 PM, Charles C. Berry [EMAIL PROTECTED] wrote:
Gabor,
Why not just this:
expos - list( B=e9, M=e6, m=e6, k=e3 )
9 matches
Mail list logo