getfile: Get a file name and path and store them in a list.

Description Usage Arguments Value Author(s) Examples

View source: R/file_handling.r

Description

getfile is a convenience function that serves as a wrapper for the functions file.choose(), file.path(), and list.files(). If the user is working in a GUI environment, a window will pop up, allowing the user to choose a specified file regardless of path.

Usage

1
getfile(multi = FALSE, pattern = NULL, combine = TRUE)

Arguments

multi

this is an indicator to allow the user to store the names of multiple files found in the directory. This is useful in conjunction with poppr.all().

pattern

a regex() pattern for use while multi == TRUE. This will grab all files matching this pattern.

combine

logical. When this is set to TRUE (default), the $files vector will have the path appended to them. When it is set to FALSE, it will have the basename.

Value

path

a character string of the absolute path to the chosen file or files

files

a character vector containing the chosen file name or names.

Author(s)

Zhian N. Kamvar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 

x <- getfile()
poppr(x$files)

y <- getfile(multi=TRUE, pattern="^.+?dat$") 
#useful for reading in multiple FSTAT formatted files.

yfiles <- poppr.all(y$files)


## End(Not run)  

poppr documentation built on Jan. 13, 2021, 8:33 a.m.