Closed MetabolomicsSA closed 4 years ago
This is a general R question, not related to svDialogs.
Since you define a function, values are assigned locally in the environment of the function, which is destroyed at the end. If you want to return several items from a function you can return a list:
Param <- function() { rtstart <- dlgInput(message = "Enter a value for rt start(in seconds)", default = 1, gui = .GUI)$res rtend <- dlgInput(message = "Enter a value for rt end(in seconds)", default = 2, gui = .GUI)$res list(start = rtstart, end = rtend) } rt <- Param() rt$start rt$end
I am not sure if this is an issue with this function or if I am doing something wrong. I want to repeat the dlgInput function several times, assigning every instance to a different object and wrap everything into a function (please see code below)
Param<-function(){ rtstart<- dlgInput(message = "Enter a value for rt start(in seconds)", default = 1, gui = .GUI)$res rtend<-dlgInput(message = "Enter a value for rt end(in seconds)", default = 2, gui = .GUI)$res } This would allow me to run the Param() function and have the 2 GUI opened subsequently. However, after running the function the input text is not stored i the defined objects (rtstart and rtend)