推荐-大智慧龙软DTSR语言量化投资云培训RStudio学习手册(中文翻译).docx
《推荐-大智慧龙软DTSR语言量化投资云培训RStudio学习手册(中文翻译).docx》由会员分享,可在线阅读,更多相关《推荐-大智慧龙软DTSR语言量化投资云培训RStudio学习手册(中文翻译).docx(45页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Working in the Console 控制台中的工作Overview 概述The RStudio console includes a variety of features intended to make working with R more productive and straightforward. This article reviews these features. Learning to use these features along with the related features available in the Source and History pan
2、es can have a substantial payoff in your overall productivity with R. RStudio控制台包含许多使R工作更为有效和直观的特征。本文综述这些特征。学习使用这些特征以及Source和History窗口中可用的相关特征可以对你使用R的效率有实际性的帮助。Code Completion 代码补全RStudio supports the automatic completion of code using the Tab key. For example, if you have an object named pollResult
3、s in your workspace you can type poll and then Tab and RStudio will automatically complete the full name of the object.RStudio支持使用Tab键来自动补全代码。例如,如果你在工作空间中有名为pollResults的对象,你可输入poll然后按Tab键,RStudio将自动完成该对象的全名。The code completion feature also provides inline help for functions whenever possible. For ex
4、ample, if you typed sub then pressed Tab you would see:代码补全特征同样提供了尽可能的嵌入式帮助。例如,如果你可输入sub然后按Tab键,你将看到:Code completion also works for function arguments, so if you typed subset( and then pressed Tab youd see the following:代码补全还可以对参数功能进行工作,如果你可输入subset(然后按Tab键,你将看到:Retrieving Previous Commands 检索以前命令As
5、 you work with R youll often want to re-execute a command which you previously entered. As with the standard R console, the RStudio console supports the ability to recall previous commands using the arrow keys:当你使用R进行工作,你将经常可输入重新执行你之前输入的命令。与标准的R控制台一样,RStudio控制台支持使用以下方向键回忆之前命令的功能: Up Recall previous
6、command(s) Down Reverse of Up Up 回忆前一条命令; Down 回Up相反;If you wish to review a list of your recent commands and then select a command from this list you can use Ctrl+Up to review the list (note that on the Mac you can also use Command-Up): 如果你希望回忆你当前的命令列表并从中选择一条命令,那么可使用Ctrl+Up来回忆命令列表注意:在Mac你还可使用Comman
7、d-UpYou can also use this same keyboard shortcut to quickly search for commands that match a given prefix. For example, to search for previous instances of the plot function simply type plot and then Ctrl+Up:你还可以使用同样的快捷键来快速查找匹配给定前缀的命令。例如,查找前面出现过的plot函数,先输入plot然后Ctrl+UpConsole Title Bar 控制台标题栏This sc
8、reenshot illustrates a few additional capabilities provided by the Console title bar:这个截屏说明了控制台标题栏的一些额外功能。 Display of the current working directory. The ability to interrupt R during a long computation. Minimizing and maximizing the Console in relation to the Source pane (using the buttons at the to
9、p-right or by double-clicking the title bar). 显示当前工作目录; 能够在一个长期的计算里中断R; 最小化和最大化Console和Source窗口使用右上按钮或双击标题栏Keyboard Shortcuts 快捷键Beyond the history and code-completion oriented keyboard shortcuts described above, there are a wide variety of other shortcuts available. Some of the more useful shortcut
10、s include: 除了上述的历史和代码补全快捷键外,还有很多其他快捷键可用,其中最为有用的快捷键包括 Ctrl+1 Move focus to the Source Editor Ctrl+2 Move focus to the Console Ctrl+L Clear the Console Esc Interrupt R Ctrl+1 移动焦点到Source编辑器。 Ctrl+2 移动焦点到Console。 Ctrl+L 清理控制台; Esc 中断RYou can find a list of all shortcuts in the Keyboard Shortcuts articl
11、e. 你可从Keyboard Shortcuts文中找到所有快捷键列表。Related Topics 相关主题 Editing and Executing Code 编辑和执行代码 Using Command History 使用命令历史Editing and Executing Code 编辑执行代码Overview 概述RStudios source editor includes a variety of productivity enhancing features including syntax highlighting, code completion, multiple-fil
12、e editing, and find/replace.RStudio的souce编辑器包含各种提高效率的特征,包括语法高亮显示,代码自动补全,多文件编辑以及查找和替换。RStudio also enables you to flexibly execute R code directly from the source editor. For many R developers this represents their preferred way of working with R. By executing commands from within the source editor r
13、ather than the console it is much easier to reproduce sequences of commands as well as package them for re-use as a function. These features are described in the Executing Code section below.RStudio还可以使你直接通过source编辑器灵活地执行R代码。对于许多R开发者来说,这是他们使用R的首选方式。通过source编辑器执行命令相对于控制台来说更便于复制命令序列和将其做为再次使用的函数进行打包;这些
14、特征将在后面的执行代码局部讲解。Managing Files 文件管理RStudio supports syntax highlighting and other specialized code-editing features for the following types of files:Rstudio支持语法高亮显示和其他专业化的代码编辑功能,针对以下类型文件。 R scripts R脚本文件 Sweave documents Sweave文件 TeX documents Tex文件To create a new file you use the File - New menu: 你
15、可通过File - New菜单创立新文件。你也可使用Ctrl+Shift+N快捷键。To open an existing file you use either the File - Open menu or the Open Recent menu to select from recently opened files. 你可通过File - Open菜单或者Open Recent菜单项选择择来翻开已有文件。你也可使用Ctrl+O快捷键。If you open several files within RStudio they are all available as tabs to f
16、acilitate quick switching between open documents. If you have a large number of open documents you can also navigate between them using the icon on the tab bar or the View - Switch to Tab) menu item:如果你通过RStudio翻开许多文件,那么他们都可以通过标签进行快速切换。如果你有大量的翻开文件,你也可在它们间通过标签栏中的图标来进行导航,或者View - Switch to Tab菜单项你也可使用
17、Ctrl+O快捷键。Code Completion 代码补全RStudio supports the automatic completion of code using the Tab key. For example, if you have an object named pollResults in your workspace you can type poll and then Tab and RStudio will automatically complete the full name of the object.RStudio可以使用Tab键来支持代码自动补全,例如,如果你
18、在工作空间中有名为pollResults的对象,你可输入poll然后按Tab键,RStudio将自动完成该对象的全名。Code completion also works in the console, and more details on using it can be found the console Code Completion documentation. 代码补全同样在控制台中工作,具体用法可间控制台代码自动完成Code Completion文档。Find and Replace 查找和替换RStudio supports finding and replacing text
19、within source documents: Rstudio支持在source文件中查找和替换。Find and replace can be opened using the Ctrl+F shortcut key, or from the Edit - Find and Replace menu item.可使用Ctrl+F快捷键来翻开查找和替换栏,或者使用Edit - Find and Replace菜单项。Extract Function 提取函数RStudio can analyze a selection of code from within the source edito
20、r and automatically convert it into a re-usable function. Any free variables within the selection (objects that are referenced but not created within the selection) are converted into function arguments:RStudio可以在source编辑器中分析一组选择的代码,并自动将其转化成再次使用的函数。任何选择中的free变量选择引用对象但不创立将转化为函数参数。你也可使用Ctrl+Shift+U快捷键
21、。Comment/Uncomment 注释/取消注释You can comment and uncomment entire selections of code using the Edit - Comment/Uncomment Lines menu item (you can also do this using the Ctrl+/ keyboard shortcut):你可使用使用Edit - Comment/Uncomment Lines菜单项来对所选的整个代码进行注释或取消注释你也可使用Ctrl+Shift+C快捷键。Indentation 首行缩进As you write R
22、code in RStudio it is automatically indented according to the current indentation options (see Customizing RStudio). R code is also re-indented: 如果你在RStudio中写R代码,他将自动根据当前的缩进选项见Customizing RStudio进行缩进。R代码也可再缩进。1. Whenever new code is pasted into a source document. 2. When the Reindent Lines command (
23、pictured above) is invoked. 当新代码黏贴到一个source文件中;当缩进行命令上图被调用Note that RStudio automatic indentation is R syntax-aware and is therefore only used on source files containing R code.注意:RStudio自动缩进针对的是R语法意识,因此,只有在包含R代码的source文件中使用Executing Code 执行代码RStudio supports the direct execution of code from within
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 推荐 智慧 DTSR 语言 量化 投资 培训 RStudio 学习 手册 中文翻译
限制150内