is.file: Test whether a file exists in a target directory, or...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/reader.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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

reader documentation built on May 2, 2019, 9:27 a.m.