is.file {reader}R Documentation

Test whether a file exists in a target directory, or alternative list of directories.

Description

Looks for a file named 'fn' in 'dir', and if not found there, broadens the search to the list or vector of directorys, 'dirs'. Returns TRUE or FALSE as to whether the file exists.

Usage

is.file(fn, dir = "", dirs = NULL, combine = TRUE)

Arguments

fn

name of the file to search for

dir

the first directory to look in (expected location)

dirs

vector/list, a set of directories to look in should the file not be found in 'dir'.

combine

if a list is given, test whether ALL files valid

Value

logical vector of whether each file was found, or if combine is true, then a single value whether ALL valid or not.

Author(s)

Nicholas Cooper nick.cooper@cimr.cam.ac.uk

See Also

find.file

Examples

orig.dir <- getwd(); setwd(tempdir()); # move to temporary dir
l.fn <- "temp.txt"
writeLines("test",con=l.fn)
some.local.files <- narm(list.files()[1:10])
print(some.local.files)
is.file(l.fn)
is.file(l.fn,dir=getwd())
is.file(some.local.files)
# add a non-valid file to the list to see what happens
is.file(c(some.local.files,"fakefile.unreal"))
is.file(c(some.local.files,"fakefile.unreal"),combine=FALSE)
unlink(l.fn)
setwd(orig.dir) # reset working dir to original

[Package reader version 1.0.6 Index]