Isn't there a cryptic footnote somewhere in the blue book that describes regular expressions as "a funny little language ..." ? Well, I'm not laughing! I've googled and Man paged, but the GREP-style solution to the following problem still eludes me: ... Using a regular expression in the "pattern" argument to list.files() to restrict the return to filenames which contain both "Elstim" and "post". E.g.,>list.files()... [133] "J30710_Control_msa_amplitude_5_25_s1-30w.pre" [134] "J30710_Elstim_msa_amplitude_5_25_s1-30w.post" [135] "J30710_Elstim_msa_amplitude_5_25_s1-30w.pre" [136] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.post" [137] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.pre" [138] "J30712_Elstim_msa_amplitude_5_25_s1-17_19-43_45_48w.post" I have not found the key to generating the logical AND equivalent of the "|" OR infix operator, a proxy for the simpleton's dream: my.list.files(pattern="*Elstim" & "*post") Thanks - Derek P.S., Of course I could always do this in stages:> elstims <- list.files(pattern = "Elstim") # all the files with "Elstim" > ElPostinos <- grep("post",elstims) # all the elstim files with "post" > my.file.list <- elstims[ElPostinos] # result: list of filenamesBut my conscience would bother me for taking the easy way out. Derek N. Eder G?teborgs Universitet Institutionen f?r klinisk neurovetenskap Klinisk Neurofysiologi Sahlgrenska universitetssjukhuset SS/SU Bl? str?ket 7, v?n 3 SE 413 45 G?teborg Sverige Tlf. +46 (031) 34 244 14 (office) NYTT! Tlf. +46 (031) 34 212 83 (laboratory) Tlf. +46 0709 / 7 212 83 (mobil) Fax. +46 (031) 82 81 63 derek.eder at neuro.gu.se Gothenburg University Institute of Clinical Neuroscience, Department of Clinical Neurophysiology Salhgrenska Hospital SU/SS SE 413 45 G?teborg Sweden -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Derek Eder" <Derek.Eder at neuro.gu.se> writes:> Isn't there a cryptic footnote somewhere in the blue book that describes regular expressions as "a funny little language ..." ? Well, I'm not laughing! > > I've googled and Man paged, but the GREP-style solution to the following problem still eludes me: > > ... Using a regular expression in the "pattern" argument to list.files() to restrict the return to filenames which > contain both "Elstim" and "post". E.g., > > >list.files() > ... > [133] "J30710_Control_msa_amplitude_5_25_s1-30w.pre" > [134] "J30710_Elstim_msa_amplitude_5_25_s1-30w.post" > [135] "J30710_Elstim_msa_amplitude_5_25_s1-30w.pre" > [136] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.post" > [137] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.pre" > [138] "J30712_Elstim_msa_amplitude_5_25_s1-17_19-43_45_48w.post" > > I have not found the key to generating the logical AND equivalent of the "|" OR infix operator, a > proxy for the simpleton's dream: my.list.files(pattern="*Elstim" & "*post")As long a you know the order, how about "Elstim.*post" ? -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> "Derek Eder" <Derek.Eder at neuro.gu.se> writes:..> > ... Using a regular expression in the "pattern" argument to > > list.files() to restrict the return to filenames which > > contain both "Elstim" and "post". E.g., > > > > >list.files() > > ... > > [133] "J30710_Control_msa_amplitude_5_25_s1-30w.pre"> > [134] "J30710_Elstim_msa_amplitude_5_25_s1-30w.post"> > [135] "J30710_Elstim_msa_amplitude_5_25_s1-30w.pre"> > [136] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.post"> > [137] "J30712_Control_msa_amplitude_5_25_s1-41_44-46_48w.pre"> > [138] "J30712_Elstim_msa_amplitude_5_25_s1-17_19-43_45_48w.post"> > > > I have not found the key to generating the logical AND equivalent ofthe "|" OR infix operator, a> > proxy for the simpleton's dream: my.list.files(pattern="*Elstim"& "*post") In this case, the quick and (very) dirty method I'd also use is: grep("Elstim",grep("post",list.files())) generalising that via recursion to match an arbitrary number of REs and "&" and "|" operators is left as an excercise.... Cheers Jason -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Seemingly Similar Threads
- Looking for some hardware answers, maybe someone on this list could help
- Off-Topic: Low Power Hardware
- POE Splitters
- CyberPower BR850ELCD ignores offdelay and turns itself back on while still on battery
- CyberPower BR850ELCD ignores offdelay and turns itself back on while still on battery