Created uigetfile
This commit is contained in:
parent
0d1396b1e5
commit
49fa9324e5
3 changed files with 44 additions and 0 deletions
|
|
@ -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
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