-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow dollar operator to have a square brackets operator as left-hand parameter. #37
Comments
@lloyddewit that's really interesting. I think you said, in #8663 that the offending a[b]$c could be "corrected" to a([b])$c? So, I really would like us to be able to run - as far as we know - scripts that run in RStudio. But RScript seems to be well defined and perhaps that should take precedence. Once we start tweaking, we don't know where to stop? So happy for either approach, with a slight preference for RScript, rather than RStudio? I wonder what your view is? |
@rdstern nearly correct, the bracket operator has 2 operands ( I agree with the rest of your comment. I suggest we leave this issue open for now. If this is a rare case, then I hope that the workaround is OK. If you hit more scripts that use thanks |
@lloyddewit as you say. If lots of code breaks the rule, then we follow RStudio. Otherwise we have the RScript "solution". In addition we keep looking for different examples - if any - where RStudio allows code that should not be permitted under the RScript rules. |
See IDEMSInternational/R-Instat#8663 .
The line that causes the problem can be simplified to
a[b]$c
.In theory, this code is not legal R. This is because the $ operator has a higher precedence than the [ operator (see extract from R documentation below). Therefore RScript evaluates the $ operator first, finds that there is no valid operand on the left-hand side and raises an error. According to the R documentation I think this is correct.
However, I ran RStudio does accept this!
Should we change RScript to be consistent with RStudio or should we be purist and follow the official R documentation?
The text was updated successfully, but these errors were encountered: