-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #5577 Errors in R-Instat repeat the previous command #5641
fixes #5577 Errors in R-Instat repeat the previous command #5641
Conversation
merge from main
- `RLink.RunScript(...)`, line 570 - Calls `Evaluate(...)` with the R script (e.g. `.temp_val <- capture.output(2+x)`) - `Evaluate(...)` returns `True` if script executed successfully, else `False` - Line 570 ignores the return value - `RLink.RunScript(...)`, lines 571-577 - Extracts and displays the value of `.temp_val` - If the script was not successful then `.temp_val` still contains its previous value (or is potentially undefined) Issue fixed by: - line 570: Check the return value of `Evaluate(...)` - If `True` then - Extract and display the value of `.temp_val` - Remove `.temp_val` (as recommended by @dannyparsons it's good to keep the R environment tidy and remove variables after using them) - Else do nothing
This looks correct. @rdstern could you test with a few examples? |
instat/clsRLink.vb
Outdated
strTemp = String.Join(Environment.NewLine, expTemp.AsCharacter()) | ||
If strTemp <> "" Then | ||
strOutput = strOutput & strTemp & Environment.NewLine | ||
If Evaluate(strTempAssignTo & " <- " & strCapturedScript, bSilent:=bSilent, bSeparateThread:=bSeparateThread, bShowWaitDialogOverride:=bShowWaitDialogOverride) = True Then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove = True
, it will do the same without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, done
…ithub.com/lloyddewit/R-Instat into lloyddewit-5577ErrorsInR-InstatRepeatPreviousCommand
@lloyddewit I have pushed changes to this branch to address Roger's issue here: #5577 (comment). Please check and merge if it looks correct. The reason this was not trapped by the original fix is that the script is slightly different: Last_Test <- cor.test( size,fert2)
data_book$add_model(model_name="Last_Test", model=Last_Test, data_name="survey")
data_book$get_models(data_name="survey", model_name="Last_Test") In The reason the last line doesn't give an error itself is that when Roger runs the dialog the first time with a correct command then it does save something called data_book$get_models(data_name="survey", model_name="Last_Test") does run, but its getting the model from the first successful run of the dialog (because the name is the same). I hope that's clear. |
…atRepeatPreviousCommand added check to capture error when displaying assigned output (multi line commands)
@dannyparsons thanks for the changes and explanation. I approved and merged. Note: |
Great. I wouldn't delete Yes definitely |
Fixes #5577. This was caused by the following:
RLink.RunScript(...)
, line 570Evaluate(...)
with the R script (e.g..temp_val <- capture.output(2+x)
)Evaluate(...)
returnsTrue
if script executed successfully, elseFalse
RLink.RunScript(...)
, lines 571-577.temp_val
.temp_val
still contains its previous value (or is potentially undefined)Issue fixed by:
Evaluate(...)
True
then.temp_val
.temp_val
(as recommended by @dannyparsons it's good to keep the R environment tidy and remove variables after using them)