【大智慧龙软DTSR语言量化投资云培训】RStudio学习手册(中文翻译(3)

2018-12-08 21:05

You can find a list of all shortcuts in the Keyboard Shortcuts article.

Related Topics 相关主题

? ? ? ?

Working in the Console 在控制台中工作 Using Command History 使用历史命令 Navigating Code 代码导航

Code Folding and Sections 代码折叠和截取

Code Folding and Sections 代码折叠和截取

Code Folding 代码折叠

RStudio supports both automatic and user-defined folding for regions of code. Code folding allows you to easily show and hide blocks of code to make it easier to navigate your source file and focus on the coding task at hand. For example, in the following source file the body of the

plot.autoregressive.model has been folded:

RStudio支持自动和使用者定义的地区代码折叠。代码折叠允许你很方便地显示和隐藏代码块,这将使你的source文件导航更简易,并可以将中重点放在手头的代码任务上。例如,在下面的source文件中plot.autoregressive.model部分已经被折叠。

You can expand the folded region by either clicking on the arrow in the gutter or on the icon that overlays the folded code.

你可展开折叠部分,通过点击箭头槽或者覆盖折叠代码的图标。

Foldable Regions 折叠区域

The following types of code regions are automatically foldable within RStudio:

RStudio中以下类型的代码区域将自动折叠:

? Braced regions (function definitions, conditional blocks, etc.) ? Code chunks within R Sweave or R Markdown documents ? Code sections (see below for details) ? 支撑区域(函数定义、条件块等)

? R Sweave的代码块或者是R的Markdown文件。 ? 代码段(具体见后文)

In the following example you can see that the top-level code section, function body, and conditional blocks are all foldable:

在以下案例中,即将看到顶级代码部分、函数体和条件块都被折叠。

You can also fold an arbitrary selection of code by using Edit -> Folding -> Collapse (Alt-L).

你也可折叠任意选定的代码,通过Edit -> Folding -> Collapse,或者使用Alt-L快捷键。

Folded regions are preserved while editing a document however when a file is closed and re-opened all foldable regions are by default shown expanded.

折叠部分在编辑文件时将被保证,但是当文件关闭或者再次打开时,所有折叠部分将默认展开显示。

Code Sections 代码段

Code sections allow you to break a larger source file into a set of discrete regions for easy navigation between them. Code sections are automatically foldable—for example, the following source file has three sections (one expanded and the other two folded):

代码段允许你将一个大型的source文件分解成一组独立的区域以方便再他们之间漫游。代码段将自动折叠,例如,以下源文件有三个部分(一个展开而另两个折叠)。

To insert a new code section you can use the Code -> Insert Section command. Alternatively, any comment line which includes at least four trailing dashes (-), equal signs (=), or pound signs (#) automatically creates a code section. For example, all of the following lines create code sections:

插入一个新的代码段你使用Code -> Insert Section命令。或者,任意注释行中包含至少四个破折号(-),等号(=)或井号(#)将自动创建代码段。

# Section One --------------------------------- # Section Two ================================= ### Section Three ############################# Note that as illustrated above the line can start any number of pound signs (#) so long as it ends with four or more -, =, or # characters.

注意:如前所述,可输入超过4个或更多的数量的#号,-,=等。

To navigate between code sections you can use the Jump To menu available at the bottom of the editor:

你可使用编辑器低端的Jump To菜单在代码段间漫游(或者使用Alt+Shift+J快捷键)。

Menu Commands and Shortcuts 菜单命令和快捷键

The following menu commands and shortcuts are available for working with folded regions and code sections:

以下菜单命令和快捷键可以对折叠区域和代码段进行操作:

? Edit -> Folding:

? Collapse — Alt+L ? Expand — Shift+Alt+L ? Collapse All — Alt+A ? Expand All — Shift+Alt+A

? Code:

? Insert Section — Ctrl+Shift+R (Cmd+Shift+R on the Mac) ? Jump To — Shift+Alt+J

Note that the Collapse All command collapses all of the outermost foldable regions (rather than all of the nested regions within the source file).

注意:Collapse All命令折叠所有外层可折叠区域(而不是源文件中的所有嵌套区域)

Related Topics

? Navigating Code 导航代码

? Editing and Executing Code 编辑和执行代码


【大智慧龙软DTSR语言量化投资云培训】RStudio学习手册(中文翻译(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:大班5、6月安全教育活动

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: