On 5/15/07, elyakhlifi mustapha <[EMAIL PROTECTED]> wrote:
> hello,
>
> I have an argument of a the list a like this
>
> > a[[18]]
> [1] "C744=(C627*C177)/100"
>
>
> and I wanna seperate the character and the mathematics symbol to use it like 
> a formula
> and why when I used the strsplit function i obtain as follow
>
> > strsplit(a[[18]], '\\W')
> [[1]]
> [1] "C744" ""     "C627" "C177" ""     "100"
>
> and as follow
>
> > strsplit(a[[18]], '\\w')
> [[1]]
>  [1] ""   ""   ""   ""   "=(" ""   ""   ""   "*"  ""   ""   ""   ")/" ""   ""
>
> I don't understand why the star "*" doesn't create space between   "C627" and 
>   "C177"
>

You can see what is going on by doing this:

> txt <- " C744=(C627*C177)/100"
> gsub("(\\w)", "[\\1]", txt)
[1] " [C][7][4][4]=([C][6][2][7]*[C][1][7][7])/[1][0][0]"
> gsub("(\\W)", "[\\1]", txt)
[1] "[ ]C744[=][(]C627[*]C177[)][/]100"


The portions within [...] are the separators and everything else is output
as content separated by those separators.

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to