在 Visual Studio 中使用 RWork with R in Visual Studio

R 是用于统计计算和图形的高度可扩展语言和环境。R is a highly extensible language and environment for statistical computing and graphics. 它是使用 GNU 通用公共许可证免费分发的工具,提供强大的社区支持,并因能够生成发布质量的绘图(包括数学符号和公式)而闻名。It's distributed for free under the GNU General Public License, enjoys strong community support, and is known for its ability to produce publication-quality plots including mathematical symbols and formulae. 若要了解详细信息,请参阅 r-project.orgR 简介You can learn more about R at r-project.org and An Introduction to R.

针对 Visual Studio 的 R 工具 (RTVS) 是使用 MIT 许可证发布的开源插件,适用于 Visual Studio 2017 和 Visual Studio 2015 Update 3(或更高版本)。R Tools for Visual Studio (RTVS) is a free, open-source extension for Visual Studio 2017 and Visual Studio 2015 Update 3 (or higher), released under the MIT license. (还有一个链接到 R 解释器二进制文件的开放源代码组件 RHost,它是使用 GNU 公共许可证 V2 进行发布的。)(A second open-source component called RHost, which links to the R interpreter binaries, is released under the GNU Public License V2.)

Note

RTVS 目前仅在 Windows 上的 Visual Studio 2017 中受支持,在 Visual Studio for Mac 中不受支持。RTVS is presently supported only in Visual Studio 2017 on Windows and not Visual Studio for Mac. 不适用于 Visual Studio 2019。It is not available for Visual Studio 2019.

若要在 Visual Studio 中使用 R,请执行以下操作:To experience R in Visual Studio:

然后,单击下面的链接,详细了解与 R 相关的功能,以及 Visual Studio 本身的常规功能。Then follow the links below to learn more about R-related features as well as the general capabilities of Visual Studio itself.

功能Feature 说明Description Visual Studio 常规文档General Visual Studio Documentation
Visual Studio 项目系统Visual Studio project system 利用方便使用的结构整理和管理相关文件,并利用实用项目模板,如 R 代码、R 文档、R Markdown、SQL 查询和存储过程。Organize and manage related files in a convenient structure, and take advantage of useful templates for items such as R code, R documentation, R Markdown, SQL queries, and stored procedures. 此外,还可以使用包管理器SQL Server 集成Also enjoy the package manager and SQL Server integration. Visual Studio 中的解决方案和项目Solutions and Projects in Visual Studio
工作区Workspace RTVS 可以绑定到本地和远程工作区,以便使用较小的数据集在本地开发 R 代码,然后在基于云且功能更强大的计算机上使用较大的数据集运行此代码。RTVS can bind to local and remote workspaces, allowing you to develop R code locally with smaller data sets, then easily run the code on more powerful cloud-based computers with much larger data sets. n/an/a
R 工具选项R Tools options 控制 RTVS 的各个方面。Control various aspects of RTVS. “选项”对话框Options dialog box
丰富编辑、IntelliSense 和代码片段Rich editing, IntelliSense, and code snippets 包括语法着色、跨所有代码和库的 IntelliSense、代码格式设置、签名帮助、转到定义、查找所有引用和代码片段等。Includes syntax coloring, IntelliSense across all your code and libraries, code formatting, signature help, Go to Definition, Find All References, code snippets, and more. 代码编辑器功能Features of the code editor
R MarkdownR Markdown R Markdown 文档有助于共享数据结果,其中 Markdown 代码块包含集成的 R 代码。R Markdown documents help you share your data results, with integrated R code inside markdown code blocks. n/an/a
交互窗口Interactive Window 提供 R 的完整 REPL 体验,以便可以在交互窗口内轻松运行源文件中的代码。Provides a full REPL experience for R with the ability to easily run code in a source file in the interactive window. n/an/a
可视化数据Visualizing data 绘图是 R 体验不可或缺的一部分,RTVS 支持使用多个独立绘图窗口(每个窗口均有各自的历史记录)和跨窗口移动绘图功能。Plotting is an integral part of the R experience, and RTVS supports multiple, independent plot windows, each with their own history and the ability to move plots between windows. 可以将绘图保存为位图和 PDF 文件,也可以将绘图以位图或元文件的形式复制到剪贴板中。Plots can be saved to bitmap and PDF files, or copied to the clipboard as a bitmap or metafile. n/an/a
变量资源管理器Variable Explorer 在全局或包特定范围中检查变量,同时还允许查看可排序的表,并将其导出为 CSV 格式。Examine variables in the global or package-specific scopes, with the ability to view sortable tables and export to CSV. n/an/a
功能完备的调试Full-featured debugging 包括与交互窗口的集成。Includes integration with the interactive window. 在 Visual Studio 中进行调试Debugging in Visual Studio

另请参阅常见问题Also see Frequently asked questions.

视频的摄像机图标movie camera icon for video 观看视频 (youtube.com),获取有关用于 Visual Studio 的 R 工具的概述(12 分 36 秒)。Watch a video (youtube.com) for an overview of R Tools for Visual Studio (12m 36s). 另请参阅更多 R 工具视频Also see more R Tools videos.

向我们发送反馈!Send us your feedback!

  1. GitHub 问题:联系 RTVS 团队的最佳方式是在 GitHub 中上报问题或使用“R 工具” > “反馈”菜单。GitHub issues: The best way to reach the RTVS team is by filing an issue on GitHub, or by using the R Tools > Feedback menu.

  2. 发送一个笑脸/哭脸图标:使用“R 工具” > “反馈”菜单,可以快速发送反馈,并附加 RTVS 日志文件,以帮助我们诊断所遇到的问题。Send a Smile / Frown: The R Tools > Feedback menu is a quick way to send feedback and attach RTVS log files to assist in the diagnosis of your issue. (如果要单独发送,请将日志写入 %temp%/RTVSlogs.zip。)如果已使用“帮助” > “反馈” > “设置”菜单命令或在安装期间选择禁用了 Visual Studio 遥测,日志记录也会被禁用。(Logs are written into %temp%/RTVSlogs.zip in case you want to send them separately.) Logging is disabled if you've opted out of Visual Studio telemetry through the Help > Feedback > Settings menu command, or during installation.

  3. 电子邮件:可以直接向团队发送反馈,地址是 rtvsuserfeedback (at) microsoft.comEmail: You can send direct feedback to the team at rtvsuserfeedback (at) microsoft.com.