[R] space in R
Gabor Grothendieck
ggrothendieck at gmail.com
Tue May 15 14:10:13 CEST 2007
1. Use this gsub:
txt <- " C744=(C627*C177)/100"
gsub("\\b|([^[:alnum:]])", " \\1 ", txt)
and then strsplit or scan as in prior response.
2. If your text consists of valid R expressions then we can use the
R parse function can traverse the tree as shown:
txt <- " C744=(C627*C177)/100"
e <- parse(text = txt)
my.print <- function(e) {
L <- as.list(e)
if (length(L) == 0) return(invisible())
if (length(L) == 1) print(L[[1]])
else sapply(L, my.print)
return(invisible())
}
my.print(e[[1]])
There is a parser for a portion of R in the Ryacas package you could
look at.
On 5/15/07, elyakhlifi mustapha <elyakhlifi_mustapha at yahoo.fr> wrote:
> hello,
> can you help me I need to seperate words and symbol in a mathematics formula as follow
>
> C744=(C627*C177)/100
>
> How could I do please?
>
>
> _____________________________________________________________________________
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list