[R] list.files wildcard

Thomas Lumley tlumley at u.washington.edu
Thu Apr 26 21:52:57 CEST 2001

On Thu, 26 Apr 2001, David White wrote:

> Hello all,
> I have a simple question:
> I have filenames that look like these:
>  "n031ku09.10msmeanc" "n031ku10.10msmeanc" "n031ku11.10msmeanc"
> [22] "n031ku12.10msmeanc" "n031ti01.10msmeanc" "n031ti02.10msmeanc"
> I also have a set of the same without the "c" at the end.
> When I run list.files(".", pattern="*ku[01-30].meanc"), I get no result.
> I'm guessing that what I have here a problem with "." as a wildcard or
> metacharacter. How do I get it to read as a literal in that expression?

No, that's not the problem. If you do
  a<-c("n031ku09.10msmeanc", "n031ku10.10msmeanc", "n031ku11.10msmeanc")
you still get no files, so the problem is with the regular expression.

[01-30] doesn't mean numbers between 01 and 30. It means a single
character that is 0, between 1 and 3, or zero

You can get nearly the right thing with
which matches numbers from 01 to 39


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