'R Objects not in global environment in VS Code

I am trying to use VS Code to run R. When I open R terminal in VS Code, I cannot find R icon on the left most column. enter image description here

I created a .r file, loaded that into VS Code, and the R icon appeared. But do I have to load a .r file in order to let VS Code show the R icon? Is it possible to activate this R icon without loading any .r file?

Question 2:

When I loaded the .r file, I could see a menu called "Global Environment". However, nothing appears here when I create an object either using the loaded .r file or directly in the terminal. I want to know how could the created objects be demonstrated in "Global Environment"? enter image description here



Solution 1:[1]

For Question 1, try to specify R as your default terminal in your JSON settings "terminal.integrated.defaultProfile.windows": "R", or specify R as your default language "files.defaultLanguage": "r",.

For Question 2, when you click on "R: (not attached)" on the bottom bar or input .vsc.attach() into the terminal, your objects should start showing up in your global environment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 coip