strsplit(x, split= " ")
2013/7/3 Dan Murphy
> I have a vector of strings that contain mathematical expressions. E.g.,
> x <- c("5 <= 7", "z = 1+2")
> and I would like to decompose each expression into its left- and
> right-hand-side components etc., output something like
>
> "5" "<=" "7"
> "z"
ditto for the 2nd argument above
> [[1]]
> `+`
>
> [[2]]
> [1] 1
>
> [[3]]
> [1] 2
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
>> -Original Message-----
>> From: r-help-boun...@r-project.org [mailto:r-help-
ilto:r-help-boun...@r-project.org] On
> Behalf
> Of Dan Murphy
> Sent: Wednesday, July 03, 2013 10:38 AM
> To: R-help@r-project.org
> Subject: [R] Splitting a string expression into components
>
> I have a vector of strings that contain mathematical expressions. E.g.,
> x <-
I have a vector of strings that contain mathematical expressions. E.g.,
x <- c("5 <= 7", "z = 1+2")
and I would like to decompose each expression into its left- and
right-hand-side components etc., output something like
"5" "<=" "7"
"z" "=" "1" "+" "2"
Is there something built into the R language
4 matches
Mail list logo