Dear all,
I am struggling with the use of regular expression. I got
> as.character(test$sample.id)
[1] "1.11" "10.11" "11.11" "113.31" "114.2" "114.3" "114.8"
and need
[1] "11" "11" "11" "31" "2" "3" "8"
I.e. remove everything before the "." .
TIA,
Bernd
_
Hi,
I am trying to use sub, regexpr on expressions like
log(D) ~ log(N)+I(log(N)^2)+log(t)
being a model specification.
The aim is to produce:
"ln D ~ ln N + ln^2 N + ln t"
The variable names N, t may change, the number of terms too.
I succeded only partially, help on regular express
> x <- scan("clipboard", what="")
Read 7 items
> x
[1] "1.11" "10.11" "11.11" "113.31" "114.2" "114.3" "114.8"
> gsub("[0-9]*\\.", "", x)
[1] "11" "11" "11" "31" "2" "3" "8"
>
Bernd Weiss wrote:
> Dear all,
>
> I am struggling with the use of regular expression. I got
>
>
>>as.char
TECTED]
> Sent: Thursday, August 18, 2005 12:10 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Regular expressions & sub
>
>
> Dear all,
>
> I am struggling with the use of regular expression. I got
>
> > as.character(test$sample.id)
> [1] "1.11"
Bernd Weiss uni-koeln.de> writes:
> I am struggling with the use of regular expression. I got
>
> > as.character(test$sample.id)
> [1] "1.11" "10.11" "11.11" "113.31" "114.2" "114.3" "114.8"
>
> and need
>
> [1] "11" "11" "11" "31" "2" "3" "8"
>
> I.e. remove everything before t
Dirk Eddelbuettel <[EMAIL PROTECTED]> writes:
> Bernd Weiss uni-koeln.de> writes:
> > I am struggling with the use of regular expression. I got
> >
> > > as.character(test$sample.id)
> > [1] "1.11" "10.11" "11.11" "113.31" "114.2" "114.3" "114.8"
> >
> > and need
> >
> > [1] "11" "1
On 18 Aug 2005 at 21:17, Peter Dalgaard wrote:
> Dirk Eddelbuettel <[EMAIL PROTECTED]> writes:
>
> > Bernd Weiss uni-koeln.de> writes:
> > > I am struggling with the use of regular expression. I got
> > >
> > > > as.character(test$sample.id)
> > > [1] "1.11" "10.11" "11.11" "113.31" "114.2
Note that [:alpha:] is a pre-defined character class and should only be
used inside []. And metacharacters need to be quoted. See ?regexp.
> f <- log(D) ~ log(N)+I(log(N)^2)+log(t)
> f1 <- deparse(f)
> f1
[1] "log(D) ~ log(N) + I(log(N)^2) + log(t)"
Now we have a string.
(f2 <- gsub("I\\((.*)
Hello,
Here is what I got after playing a little bit with your problem:
# First of all, if you prefer 'ln' instead of 'log', why not to define:
ln <- function(x) log(x)
ln2 <- function(x) log(x)^2
ln3 <- function(x) log(x)^3
ln4 <- function(x) log(x)^4
# ... as many function as powers you need
#
There are some interactive regex tools around. I use a python one
sometimes. You just then have to be careful re escaping and the style
of regular expressions used in the tool you worked with and the target
environment.
Christian Hoffmann wrote:
> Hi,
>
> I am trying to use sub, regexpr on e
In this post:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/30590.html
Thomas Lumley provided a function to traverse a formula recursively.
We can modify it as shown to transform ln(m)^n to ln^n(m) producing
proc2. We then bundle everything up into proc3 which uses substitute
to transl
11 matches
Mail list logo