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 -- Olivier Houix <houix at ircam.fr> tel: 01 44 78 15 51 Equipe Perception et Cognition Musicales http://www.ircam.fr/ IRCAM 1 place Igor Stravinsky 75004 Paris -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Olivier Houix <Olivier.Houix at ircam.fr> writes:> 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"Read up on regular expressions (or see the last example on the help page) and:> s <- "Fd4+1/4" > strsplit(s,"\\+")[[1]] [1] "Fd4" "1/4" -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
oups! I realize I didn't use the extension "extended" extended -> if TRUE, extended regular expression matching is used, and if FALSE basic regular expressions are used. I must read more carefully the help page!! Sorry, Olivier Houix -- Olivier Houix <houix at ircam.fr> tel: 01 44 78 15 51 Equipe Perception et Cognition Musicales http://www.ircam.fr/ IRCAM 1 place Igor Stravinsky 75004 Paris -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._