I would like to get user input via the dlgInput command and compare the result with data obtained from the Internet and with existing objects in R.
If both are true, then continue, however if at least one is false, warn user and ask again to input with dlgInput.
Here are the separate lines of code that I need to use:
library(svDialogs)
ticker <- toupper(dlgInput(paste("Enter a ticker (these are already loaded:", toString(stripExtension), ")"), "e.g., AAPL")$res)
library(quantmod)
getSymbols(ticker)
exists(ticker)
Here is a sample code (found here) of where I think I should stick the above lines, but I can't figure out how:
myFun <- function(input=NULL) {
if (is.null(input)) {
message("No 'input' value defined. Using 'ns' by default")
input <- "ns"
}
if (!input %in% ticker) stop("Invalid 'input' value")
input
}
Any help really highly appreciated.
System used:
- R version: 4.1.1 (2021-08-10)
- RStudio version: 1.4.1717
- OS: macOS Catalina version 10.15.7
Aucun commentaire:
Enregistrer un commentaire