[R] excluding on element from a list
Jim Lemon
jim at bitwrit.com.au
Mon May 24 11:55:34 CEST 2010
On 05/24/2010 05:40 PM, Daisy Englert Duursma wrote:
> Dear List,
>
> I am making a list of all the files in a folder and I want to exclude
> one file called "proj.current". This is the 31st file in a folder.
> Currently I use the command:
>
> tdirs<- list.files(pattern="proj.")[-31]
>
> However I would like to exclude it based on its name and not the position.
>
Hi Daisy,
I think that:
file_list<-list.files(pattern="proj[.]")
tdirs<-file_list[!as.logical(match(file_list,"proj.current",0))]
should do the trick.
Jim
More information about the R-help
mailing list