Question
How do I use VS Code as the integrated development environment (IDE) in a conda environment for Python and R development on a Mac?
Answer
1. Using Terminal, create conda environment for use with R, enter "conda create -n <env-name> -c conda-forge r-base r-essentials r-languageserver".
Example environment: r_env_t4
How-To: Rstudio: Create Conda Environment for Using Rstudio
2. Activate new conda environment, enter "conda activate <env-name>".
Example environment: r_env_t4
How-To: Using Anaconda - Activate a Virtual Conda Environment via Command Line Interface
3. Add VS Code path to launch VS Code in activated conda environment, enter the below.
cat << EOF >> ~/.zprofile
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
4. Load file created in step 3, enter "source ~/.zprofile".
5. Launch VS Code from the terminal, enter "code".

6. In VS Code, install Python extension by Microsoft.
a. Select Extensions icon.
b. Enter "python" in Extensions: Marketplace search box.
c. Select "Install" for the Python language support... by Microsoft.

7. Install R extension by REditorSupport.
a. Enter "R" in Extensions: Marketplace search box.
b. Select "Install" for the R Extension for Visual Studio Code by REditorSupport.

8. Extensions installed.

9. Create new project folder.
a. Select Explorer icon.
b. Create new project folder.
c. Enter new project folder name.

10. Create a new R file in project directory
11. Add command print("Hello!") to new file.
12. Run file to verify R integration.

13. Verify operation and integration.
a. Confirm output "Hello!".
b. Confirm R version is displayed.
c. Enter R.home() and confirm result path is within active conda environment.
Example: /Users/<username>/miniconda3/envs/r_t4_env/lib/R

For Additional Assistance
https://code.visualstudio.com/docs/languages/r