Created uigetfile
This commit is contained in:
parent
0d1396b1e5
commit
49fa9324e5
3 changed files with 44 additions and 0 deletions
25
R/uigetfile.R
Normal file
25
R/uigetfile.R
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#' @title Select a file for loading
|
||||
#' @description Loosely mimics the functionality of the `uigetfile` function on
|
||||
#' Matlab.
|
||||
#' @references https://se.mathworks.com/help/matlab/ref/uigetfile.html
|
||||
#' @param title Pre-prompt message
|
||||
#' @export
|
||||
uigetfile <- function(title = "") {
|
||||
# ==========================================================================
|
||||
# Pre-prompt message
|
||||
# ==========================================================================
|
||||
cat(title)
|
||||
# ==========================================================================
|
||||
# Reading file path and name
|
||||
# ==========================================================================
|
||||
filepath <- readline(
|
||||
paste0("Enter file path (leave empty for ", getwd(), "): ")
|
||||
)
|
||||
if (filepath == "") filepath <- getwd()
|
||||
filename <- file.choose()
|
||||
# ==========================================================================
|
||||
# Organizing output
|
||||
# ==========================================================================
|
||||
out <- list(name = filename, path = filepath)
|
||||
return(out)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue