r - R未显示在终端中
问题描述
我是 VS Code 的新手,正在尝试在那里使用 R。我想我已经正确安装了所有必需的子程序。当尝试打印“Hello World”时,输出选项卡会产生让我认为 VS Code 正在识别 R 代码的消息。此外,我可以将鼠标悬停在 VS Code 中的 R 代码上,然后弹出解释 R 函数的提示;所以我认为我做对了一些事情。
我注意到 VS Code 屏幕的右下角显示“R:(未附加)”
当我单击它并尝试附加它时,我得到了这个:
PS C:\Users\Bob > .vsc.attach()
At line:1 char:13
+ .vsc.attach()
+ ~
An expression was expected after '('.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedExpression
在终端中,如果我单击 Powershell 旁边的向下箭头,我会得到以下选项:
PowerShell(Default)
Command Prompt
JavaScipt Debug Terminal
Split Terminal
Configure Terminal Settings
Select Default Profile
要访问我的 JSON 文件,我转到查看 >> 命令面板,然后键入“打开设置 JSON”。它包含以下内容:
{
"workbench.colorTheme": "Default Light+",
"r.alwaysUseActiveTerminal": true,
"r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe",
"security.workspace.trust.untrustedFiles": "open",
"files.associations": {
"*.R": "r"
},
"r.lsp.debug": true,
"r.rterm.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe",
"r.bracketedPaste": true,
"r.source.focus": "terminal",
"r.rterm.option": [
"--no-save",
"--no-restore",
"--r-binary=C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe"
],
"terminal.external.windowsExec": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe"
}
我现在没有使用弧度。我想让基本的 R 在 VSCode 中工作,然后我将与 Radian 联系。
它一直在尝试使用 PowerShell 运行我的 R 脚本,我认为这是主要问题。我该怎么做才能让它使用 R 运行?谢谢。
解决方案
根据您的 JSON 设置中的内容,如果您删除\\x64
部分路径r.path.windows
和r.term.windows
路径,它应该可以工作:
"r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
"r.rterm.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\R.exe",
// truncated
更改后,您应该可以使用终端窗口中的下拉菜单切换到 R 终端。
此外,您可以通过在 JSON 设置中添加附加行来将 R 设置为默认终端:
"terminal.integrated.defaultProfile.windows": "R",
// truncated
推荐阅读
- reactjs - 测试 React Native App 时如何避免集成 ios?
- authentication - 如何在微服务架构中将 Auth 服务与其他服务解耦?
- laravel - 更新或创建总是创建 | 如何使用它?
- docusignapi - 再次触发信封的事件通知
- angular - 模块中的指令未执行
- c - 计算数组中整数的平均值
- jquery - 我无法执行 ajax 请求并获得 json 响应
- vba - 如何使用正确的驱动程序为 w10 64 位 ms-access odbc 创建用户 dsn
- rust - 如何在不使用克隆的情况下迭代向量并比较元素以防止借用错误
- javascript - 动态创建对象数组错误修复