r在win10上没有附加在VS代码中

发布于 2025-01-26 16:44:55 字数 969 浏览 0 评论 0原文

我最近从rstudio切换到VS代码。我已经在VS代码中安装了R扩展名,但是当我打开VS代码和R终端时,R会加载R。我遵循CoIP的方法,但仍然无法加载R:

################################################ ###################################### 我遵循了Coip的建议,R被成功激活。在我的另一台笔记本电脑(Win)中,可以无需任何问题即可激活R。但是,当我检查settings.json文件时,没有r.rterm.windows的规范。 我想问一下为什么我的笔记本电脑可以在VS代码中成功加载r,而不必包括COIP建议的那些代码段

{
    "workbench.colorTheme": "Default Dark+",
    "python.formatting.provider": "yapf",
    "security.workspace.trust.untrustedFiles": "open",
    "python.defaultInterpreterPath": "C:\\Users\\Patrick Wen\\AppData\\Local\\Programs\\Python\\Python310\\python.exe",
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "files.associations": {
        "*.rmd": "markdown"
    }
}

I am recently switching from RStudio to VS Code. I have installed R extension in VS Code, but when I open VS Code and R terminal, R cannot be loaded. I followed coip's method but still cannot get R loaded:
enter image description here

##############################################################################
I followed coip's suggstion and R is successfully activated. In another of my laptop (Win), R could be activated without any issue. But when I check the settings.json file, there is no such specification as r.rterm.windows. I want to ask why my laptop could successfuly load R in VS Code without having to include those code snippet suggested by coip?

Below is the settings.json in my laptop:

{
    "workbench.colorTheme": "Default Dark+",
    "python.formatting.provider": "yapf",
    "security.workspace.trust.untrustedFiles": "open",
    "python.defaultInterpreterPath": "C:\\Users\\Patrick Wen\\AppData\\Local\\Programs\\Python\\Python310\\python.exe",
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "files.associations": {
        "*.rmd": "markdown"
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

归途 2025-02-02 16:44:55

如果这是您的完整settings.json,则缺少常见参数,例如r.rpath.windows- r-binaryr.rterm.option下。我相信添加这些,与当前有关r.rpath.windows的R的路径相同,应该解决您的问题。

这是一个典型的设置,您可以将其复制并粘贴到JSON设置中,您可以通过View>命令调色板>首选项:打开设置(JSON):

{
// R Options
"r.rterm.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
"r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
"r.lsp.path": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
"r.lsp.debug": true,
"r.lsp.diagnostics": true,
"r.alwaysUseActiveTerminal": true,
"r.rterm.option": [
    "--no-save",
    "--no-restore",
    "--r-binary=C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe"
],
"r.bracketedPaste": true,
"r.sessionWatcher": true
}

注意:其中一些只是首选项(例如R.BracketedPaste)。

因此,您可以尝试添加上述所有或以上某些内容,保存JSON设置,然后重新启动VSCODE,直到解决问题为止。

如果这不起作用,让我们尝试通过将以下内容添加到您的settings.json

"terminal.integrated.profiles.windows": {
   "PowerShell": {
       "source": "PowerShell",
       "icon": "terminal-powershell"
   },
   "Command Prompt": {
       "path": [
          "${env:windir}\\Sysnative\\cmd.exe",
          "${env:windir}\\System32\\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
   },
   "R": {
       "path": [
           "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe"
       ]
   },
},  

您也可以尝试通过上面添加以下以下行来制作R:

"terminal.integrated.defaultProfile.windows": "R",

If that is your complete settings.json, you're missing common parameters such as r.rpath.windows and the --r-binary under r.rterm.option. I believe adding those, with the same path to R that you currently have for r.rpath.windows should fix your issue.

Here is a typical setup that you can copy and paste into your JSON settings, which you can access via View > Command Palette > Preferences: Open Settings (JSON):

{
// R Options
"r.rterm.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
"r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
"r.lsp.path": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
"r.lsp.debug": true,
"r.lsp.diagnostics": true,
"r.alwaysUseActiveTerminal": true,
"r.rterm.option": [
    "--no-save",
    "--no-restore",
    "--r-binary=C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe"
],
"r.bracketedPaste": true,
"r.sessionWatcher": true
}

Note: some of those are just preferences (e.g. r.bracketedPaste).

So you can try to add all of the above or some of the above, save your JSON settings, and relaunch VSCode, until the problem is fixed.

If that doesn't work, let's try setting up an integrated profile, by adding the following to your settings.json:

"terminal.integrated.profiles.windows": {
   "PowerShell": {
       "source": "PowerShell",
       "icon": "terminal-powershell"
   },
   "Command Prompt": {
       "path": [
          "${env:windir}\\Sysnative\\cmd.exe",
          "${env:windir}\\System32\\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
   },
   "R": {
       "path": [
           "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe"
       ]
   },
},  

You can also try making R your default terminal by adding the following line above too:

"terminal.integrated.defaultProfile.windows": "R",
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文