mauede at alice.it
2010-Feb-02 15:09 UTC
[R] finding files whose name does NOT contain a given character
Unluckily I dela with miRNA files whose name may contain the character "*". Because of the special meaning of "*" I have to remove it. I found out how to make list.files() extract only those file names which contain a "*" Namely: # list.files(pattern="\\*") Now I have to process all files whose name does NOT contain the character "*". I cannot have list.files() extract all files whose name does NOT match pattern="\\* I tried using "^" in such a pattern but nothing is returned. Any suggestion is welcome. Thank you so much, Maura tutti i telefonini TIM! [[alternative HTML version deleted]]
Peter Dalgaard
2010-Feb-02 15:18 UTC
[R] finding files whose name does NOT contain a given character
mauede at alice.it wrote:> Unluckily I dela with miRNA files whose name may contain the character "*". > Because of the special meaning of "*" I have to remove it. > I found out how to make list.files() extract only those file names which contain a "*" > Namely: > # list.files(pattern="\\*") > > Now I have to process all files whose name does NOT contain the character "*". > I cannot have list.files() extract all files whose name does NOT match pattern="\\* > I tried using "^" in such a pattern but nothing is returned. > Any suggestion is welcome.That'll be something like pattern="^[^*]*$" (untested, I don't think I have any filenames with "*" inside...) Alternatively, you might try allfiles <- list.files() withstar <- allfiles[grepl("\\*", allfiles)] nostar <- allfiles[!grepl("\\*", allfiles)] -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Erik Iverson
2010-Feb-02 15:22 UTC
[R] finding files whose name does NOT contain a given character
mauede at alice.it wrote:> Unluckily I dela with miRNA files whose name may contain the character "*". > Because of the special meaning of "*" I have to remove it. > I found out how to make list.files() extract only those file names which contain a "*" > Namely: > # list.files(pattern="\\*") > > Now I have to process all files whose name does NOT contain the character "*". > I cannot have list.files() extract all files whose name does NOT match pattern="\\* > I tried using "^" in such a pattern but nothing is returned. > Any suggestion is welcome. > > Thank you so much, > Maura > >Maybe ?setdiff could even help here ...> tutti i telefonini TIM! > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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.