[R] about strsplit

Roger Bivand rsb at reclus.nhh.no
Thu May 10 11:54:36 CEST 2001


What about:

> strsplit(s,"+", extended=FALSE)
[[1]]
[1] "Fd4" "1/4"

(When extended is FALSE, "+" is not treated as an extended regular
expression, but as a basic reg.exp, in which "+" doesn't interfere).

Roger


On Thu, 10 May 2001, Olivier Houix wrote:

> Hello,
> I want to split a string including a "+" but 
> it seems there is no effect because of this special character.
> Just to explain, I convert frequencies to midi notes (external program)
> but I don't want to keep 
> information about quater-tone!
>  
> > s <- c("Fd4+1/4") (i't a note!)
> > strsplit(s,"+")
> [[1]]
> [1] "F" "d" "4" "+" "1" "/" "4"
> 
> but
> > strsplit(s,"d")
> [[1]]
> [1] "F"     "4+1/4"
> So the problem is "+" !
> 
> I would prefer to obtain:
> "Fd4" "1/4"
> 
> Thanks
> 
> Olivier Houix
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list