Merge branch 'uigetfile' into dev
This commit is contained in:
commit
8172045a64
3 changed files with 44 additions and 0 deletions
|
|
@ -26,5 +26,6 @@ export(size)
|
||||||
export(strcmp)
|
export(strcmp)
|
||||||
export(suoritaMuutos)
|
export(suoritaMuutos)
|
||||||
export(times)
|
export(times)
|
||||||
|
export(uigetfile)
|
||||||
importFrom(methods,is)
|
importFrom(methods,is)
|
||||||
importFrom(stats,runif)
|
importFrom(stats,runif)
|
||||||
|
|
|
||||||
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)
|
||||||
|
}
|
||||||
18
man/uigetfile.Rd
Normal file
18
man/uigetfile.Rd
Normal 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
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue