diff --git a/NAMESPACE b/NAMESPACE index 01d0b49..9b2f730 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -26,5 +26,6 @@ export(size) export(strcmp) export(suoritaMuutos) export(times) +export(uigetfile) importFrom(methods,is) importFrom(stats,runif) diff --git a/R/uigetfile.R b/R/uigetfile.R new file mode 100644 index 0000000..217684d --- /dev/null +++ b/R/uigetfile.R @@ -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) +} \ No newline at end of file diff --git a/man/uigetfile.Rd b/man/uigetfile.Rd new file mode 100644 index 0000000..34e15bb --- /dev/null +++ b/man/uigetfile.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/uigetfile.R +\name{uigetfile} +\alias{uigetfile} +\title{Select a file for loading} +\usage{ +uigetfile(title = "") +} +\arguments{ +\item{title}{Pre-prompt message} +} +\description{ +Loosely mimics the functionality of the `uigetfile` function on +Matlab. +} +\references{ +https://se.mathworks.com/help/matlab/ref/uigetfile.html +}