deparse and substitute under RStudio console

Hi all,

I am experiencing different results between RStudio and plain R, using deparse(substitute()), with the following reprex:

foo <- function(x) {
    return(deparse(substitute(x)))
}

foo(1 - x)
#> [1] "`-`(1, x)"

The result should be "1 - x", which I get from plain R.
Interestingly, package reprex also gave the correct result, but this is not the case when used in the RStudio console.

what do you consider to be plain R ? Rgui64 ? Rterm ?
I tried to reproduce your result. I'm using
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
with RStudio 1.3.1
and running your code example in the console of that gives me your desired result "1 - x" and not "-(1,x)"

Oh, I should have probably specified more details.
Plain R is both Rgui and Rterm, I get correct results in both the usual Rgui console and under a Terminal.

But the Operating System is MacOS Monterey version 12.0.1, with:

> R.version
               _                           
platform       x86_64-apple-darwin17.0     
arch           x86_64                      
os             darwin17.0                  
system         x86_64, darwin17.0          
status                                     
major          4                           
minor          1.1                         
year           2021                        
month          08                          
day            10                          
svn rev        80725                       
language       R                           
version.string R version 4.1.1 (2021-08-10)
nickname       Kick Things 

The version of RStudio I'm using is: Version 1.4.1717
EDIT: I've just upgraded RStudio to version 2021.09.1 Build 372, still the same issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.