Hello Boris, thanks for your response. So, firstly considered that i've been input a set of serches strings (.txt format) and i'm using regex to transform in a suitable format to my script. This part is a final part of my code and i wish putting in input to a subset. (.txt formatted) ---- STRINGS (INPUT) *[1] "municipio =='Limeira' "* *[2] "municipio =='Limeira' & mesincident =='marco' "* *[3] "?municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 12.300"* *...* *..* *..* *..* *[n] "......"* *--------------* desired_fomart <- ?it will reveice all strings to filter in a dataset by subset below: a loop each line: subset(dataset_read, *desired_fomart[i]*) My question: taking into consideration this cenario, in your oppinion your reply is my suitable for my problem, whereas i will to map each value in database? Once again, thank so much! :) 2015-04-18 11:04 GMT-03:00 Boris Steipe <boris.steipe at utoronto.ca>:> This is not a regular expression but simply a conjunction (sequence of > '&') of logical expressions. Moreover it's not wrong. Consider: > > xyz <- data.frame(municipio = c('Limeira'), mesincident = c('marco'), > trechoklmetros = c(3.00, -4.00, 30)) > xyz > > municipio mesincident trechoklmetros > 1 Limeira marco 3 > 2 Limeira marco -4 > 3 Limeira marco 30 > > > xyz$municipio =='Limeira' & xyz$mesincident =='marco' & xyz$trechoklmetros > > 1.00 > [1] TRUE FALSE TRUE > > xyz$municipio =='Limeira' & xyz$mesincident =='marco' & xyz$trechoklmetros > > 1.00 & xyz$trechoklmetros <= 12.3 > [1] TRUE FALSE FALSE > > > If there's a problem it seems to be elsewhere. > Cheers, > Boris > > > On Apr 17, 2015, at 4:22 PM, Fernando Gama <f.fabiogama88 at gmail.com> > wrote: > > > Hello, > > > > I have benn problems to construct the pattern for this: > > > > municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 > 12.300 > > > > I would like: > > > > municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 > > *& **trechoklmetros > > <= *12.300 > > ? > > ?Any suggestion?? > > > > > > -- > > Att, > > > > Fernando Gama da Mata > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > >-- Att, Fernando Gama da Mata [[alternative HTML version deleted]]
Sorry - it's not entirely clear to me what you need to do. See here for some hints on how to ask questions on this list. I'm sure we'll be able to help quickly. http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example (and don't post in HTML :-) B. On Apr 18, 2015, at 11:10 AM, Fernando Gama <f.fabiogama88 at gmail.com> wrote:> Hello Boris, > > thanks for your response. > > So, firstly considered that i've been input a set of serches strings (.txt format) and i'm using regex to transform in a suitable format to my script. This part is a final part of my code and i wish putting in input to a subset. > > (.txt formatted) > > ---- STRINGS (INPUT) > > [1] "municipio =='Limeira' " > [2] "municipio =='Limeira' & mesincident =='marco' " > [3] "?municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 12.300" > ... > .. > .. > .. > [n] "......" > > -------------- > > desired_fomart <- ?it will reveice all strings to filter in a dataset by subset below: > > > a loop each line: > > subset(dataset_read, desired_fomart[i]) > > My question: taking into consideration this cenario, in your oppinion your reply is my suitable for my problem, whereas i will to map each value in database? > > Once again, thank so much! :) > > 2015-04-18 11:04 GMT-03:00 Boris Steipe <boris.steipe at utoronto.ca>: > This is not a regular expression but simply a conjunction (sequence of '&') of logical expressions. Moreover it's not wrong. Consider: > > xyz <- data.frame(municipio = c('Limeira'), mesincident = c('marco'), trechoklmetros = c(3.00, -4.00, 30)) > xyz > > municipio mesincident trechoklmetros > 1 Limeira marco 3 > 2 Limeira marco -4 > 3 Limeira marco 30 > > > xyz$municipio =='Limeira' & xyz$mesincident =='marco' & xyz$trechoklmetros > 1.00 > [1] TRUE FALSE TRUE > > xyz$municipio =='Limeira' & xyz$mesincident =='marco' & xyz$trechoklmetros > 1.00 & xyz$trechoklmetros <= 12.3 > [1] TRUE FALSE FALSE > > > If there's a problem it seems to be elsewhere. > Cheers, > Boris > > > On Apr 17, 2015, at 4:22 PM, Fernando Gama <f.fabiogama88 at gmail.com> wrote: > > > Hello, > > > > I have benn problems to construct the pattern for this: > > > > municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 12.300 > > > > I would like: > > > > municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 > > *& **trechoklmetros > > <= *12.300 > > ? > > ?Any suggestion?? > > > > > > -- > > Att, > > > > Fernando Gama da Mata > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > > > -- > Att, > > Fernando Gama da Mata > >
Re-reading your question and taking a wild guess, perhaps you are looking for parse() and eval() ... xyz <- data.frame( a=c(1,2), b=c(3,4)) xyz a b 1 1 3 2 2 4 expp <- parse(text="xyz$a > 1 & xyz$b == 4") # turn a string into an expression expp expression(xyz$a > 1 & xyz$b == 4) xyz[eval(expp), ] # evaluate an expression in place a b 2 2 4 ... but really, it's just a guess at what you might be trying to do. B. On Apr 18, 2015, at 1:30 PM, Boris Steipe <boris.steipe at utoronto.ca> wrote:> Sorry - it's not entirely clear to me what you need to do. > > See here for some hints on how to ask questions on this list. I'm sure we'll be able to help quickly. > http://adv-r.had.co.nz/Reproducibility.html > http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example > (and don't post in HTML :-) > > > B. > > On Apr 18, 2015, at 11:10 AM, Fernando Gama <f.fabiogama88 at gmail.com> wrote: > >> Hello Boris, >> >> thanks for your response. >> >> So, firstly considered that i've been input a set of serches strings (.txt format) and i'm using regex to transform in a suitable format to my script. This part is a final part of my code and i wish putting in input to a subset. >> >> (.txt formatted) >> >> ---- STRINGS (INPUT) >> >> [1] "municipio =='Limeira' " >> [2] "municipio =='Limeira' & mesincident =='marco' " >> [3] "?municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 12.300" >> ... >> .. >> .. >> .. >> [n] "......" >> >> -------------- >> >> desired_fomart <- ?it will reveice all strings to filter in a dataset by subset below: >> >> >> a loop each line: >> >> subset(dataset_read, desired_fomart[i]) >> >> My question: taking into consideration this cenario, in your oppinion your reply is my suitable for my problem, whereas i will to map each value in database? >> >> Once again, thank so much! :) >> >> 2015-04-18 11:04 GMT-03:00 Boris Steipe <boris.steipe at utoronto.ca>: >> This is not a regular expression but simply a conjunction (sequence of '&') of logical expressions. Moreover it's not wrong. Consider: >> >> xyz <- data.frame(municipio = c('Limeira'), mesincident = c('marco'), trechoklmetros = c(3.00, -4.00, 30)) >> xyz >> >> municipio mesincident trechoklmetros >> 1 Limeira marco 3 >> 2 Limeira marco -4 >> 3 Limeira marco 30 >> >> >> xyz$municipio =='Limeira' & xyz$mesincident =='marco' & xyz$trechoklmetros > 1.00 >> [1] TRUE FALSE TRUE >> >> xyz$municipio =='Limeira' & xyz$mesincident =='marco' & xyz$trechoklmetros > 1.00 & xyz$trechoklmetros <= 12.3 >> [1] TRUE FALSE FALSE >> >> >> If there's a problem it seems to be elsewhere. >> Cheers, >> Boris >> >> >> On Apr 17, 2015, at 4:22 PM, Fernando Gama <f.fabiogama88 at gmail.com> wrote: >> >>> Hello, >>> >>> I have benn problems to construct the pattern for this: >>> >>> municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 12.300 >>> >>> I would like: >>> >>> municipio =='Limeira' & mesincident =='marco' & trechoklmetros > 1.00 >>> *& **trechoklmetros >>> <= *12.300 >>> ? >>> ?Any suggestion?? >>> >>> >>> -- >>> Att, >>> >>> Fernando Gama da Mata >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> 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. >> >> >> >> >> -- >> Att, >> >> Fernando Gama da Mata >> >> > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.