diff --git a/NAMESPACE b/NAMESPACE index afc1b39..816fc08 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ export(computeIndLogml) export(computePersonalAllFreqs) export(computeRows) export(etsiParas) +export(inputdlg) export(isfield) export(laskeMuutokset4) export(learn_simple_partition) diff --git a/R/inputdlg.R b/R/inputdlg.R new file mode 100644 index 0000000..c803ddc --- /dev/null +++ b/R/inputdlg.R @@ -0,0 +1,17 @@ +#' @title Gather user input +#' @description Replicates the functionality of the homonymous function in Matlab (sans dialog box) +#' @param prompt Text field with user instructions +#' @param dim number of dimensions in the answwers +#' @param definput default value of the input +#' @export +inputdlg <- function(prompt, definput=NULL, dims=1) { + if (!is.null(definput)) { + prompt <- append(prompt, paste0(" (default: ", definput, ")")) + } + input_chr <- readline(paste0(prompt, ": ")) + if (input_chr == "") input_chr <- definput + input_chr_or_num <- tryCatch( + as.numeric(input_chr), warning = function(w) input_chr + ) + return(input_chr_or_num) +} \ No newline at end of file diff --git a/man/inputdlg.Rd b/man/inputdlg.Rd new file mode 100644 index 0000000..0df8bad --- /dev/null +++ b/man/inputdlg.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/inputdlg.R +\name{inputdlg} +\alias{inputdlg} +\title{Gather user input} +\usage{ +inputdlg(prompt, dims = 1, definput = NULL) +} +\arguments{ +\item{prompt}{Text field with user instructions} + +\item{definput}{default value of the input} + +\item{dim}{number of dimensions in the answwers} +} +\description{ +Replicates the functionality of the homonymous function in Matlab (sans dialog box) +}