Description Usage Arguments Value Author(s) See Also Examples
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 the full path of the first match that exists.
1 |
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'. |
if the file is found, returns the full path of the file, else returns an empty string ""
Nicholas Cooper nick.cooper@cimr.cam.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | orig.dir <- getwd(); setwd(tempdir()); # move to temporary dir
l.fn <- "temp.txt"
writeLines("test",con=l.fn)
find.file(l.fn)
find.file(l.fn,dir=getwd())
unlink(l.fn)
# not run # common.places <- ## <<add local folder here>> ##
# not run # d.fn <- cat.path(common.places[1],l.fn)
# write this example file to the first of the folders #
# not run # if(!file.exists(d.fn)) { writeLines("test2",con=d.fn) }
# search the local folders for a
# a file named 'temp.txt'
# not run # find.file(l.fn,dir=getwd(),dirs=common.places)
# unlink(d.fn) # run only if test file produced
setwd(orig.dir) # reset working dir to original
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.