From 3962c8c0e881fabd42b7bd2fb724af1c2ffa40d1 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Wed, 20 May 2020 13:09:11 +0200 Subject: [PATCH] Added listing of files --- R/uigetfile.R | 8 +++++++- man/uigetfile.Rd | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/R/uigetfile.R b/R/uigetfile.R index 41e347d..ccddb99 100644 --- a/R/uigetfile.R +++ b/R/uigetfile.R @@ -2,9 +2,10 @@ #' @description Loosely mimics the functionality of the `uigetfile` function on #' Matlab. #' @references https://se.mathworks.com/help/matlab/ref/uigetfile.html +#' @param filter Filter listed files #' @param title Pre-prompt message #' @export -uigetfile <- function(title = "") { +uigetfile <- function(filter = "", title = "") { # ========================================================================== # Pre-prompt message # ========================================================================== @@ -16,6 +17,11 @@ uigetfile <- function(title = "") { paste0("Enter file path (leave empty for ", getwd(), "): ") ) if (filepath == "") filepath <- getwd() + # ========================================================================== + # Presenting possible files + # ========================================================================== + message("Files present on that directory:") + print(list.files(path = filepath, pattern = filter, ignore.case = TRUE)) filename <- file.choose() # ========================================================================== # Organizing output diff --git a/man/uigetfile.Rd b/man/uigetfile.Rd index 34e15bb..21594ba 100644 --- a/man/uigetfile.Rd +++ b/man/uigetfile.Rd @@ -4,9 +4,11 @@ \alias{uigetfile} \title{Select a file for loading} \usage{ -uigetfile(title = "") +uigetfile(filter = "", title = "") } \arguments{ +\item{filter}{Filter listed files} + \item{title}{Pre-prompt message} } \description{