Created uigetfile

This commit is contained in:
Waldir Leoncio 2020-05-20 10:27:37 +02:00
parent 0d1396b1e5
commit 49fa9324e5
3 changed files with 44 additions and 0 deletions

View file

@ -26,5 +26,6 @@ export(size)
export(strcmp)
export(suoritaMuutos)
export(times)
export(uigetfile)
importFrom(methods,is)
importFrom(stats,runif)

25
R/uigetfile.R Normal file
View 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)
}

18
man/uigetfile.Rd Normal file
View file

@ -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
}