Do it in a two step process since you want the negation.

> x <- c('file1.xyz', 'file2.xml', 'file3.abc')
> x[-grep("xml$", x)]
[1] "file1.xyz" "file3.abc"
>


On Wed, Oct 1, 2008 at 12:33 AM, zack holden <[EMAIL PROTECTED]> wrote:
>
> Greetings R list,
>
> I am stuck on a simple syntax problem. I want to list all files in a 
> directory, excluding files of a certain type. I have tried pattern matching 
> as follows:
>
>
> a <- list.files(data, full.name = TRUE, pattern != ".xml")  # exclude all 
> .xml files
>
>
> The warning returns that my syntax is incorrect. I have read the regexpr help 
> files and search old posts to no avail. I'd be grateful if anyone would show 
> me the proper syntax for specifying exclusion of certain file types.
>
> Thanks in advance for any help,
>
> Zack
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

______________________________________________
R-help@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.

Reply via email to