版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、控制台中的工作availableintheSourceandHistorypanescanhaveasubstantialpayoffinyouroverallproductivitywithR.RStudio控制台包含许多使R工作更为有效和直观的特征。本文综述这些特征。学习使用这些特征以及source和History窗口中可用的相关特征可以对你使用R的效率有实际性的帮助。thefullnameoftheobject.RStudio支持使用来自动补全代码。例如,如果你在工作空间中有名为pollResult的对象,你可输入piH然后按_,RStugo将自动完成该对象的全名。Thecodecomp
2、letionfeaturealsoprovidesinlinehelpforfuncflfcnsWHfeVfpsible.Forexample,ifyoutypedSubthenpressedyouwouldsee:代码补全特征同样提供了尽可能的嵌入式帮助。例如,如果你可输入sub然后按键,你将看到:匚onsole-ysubImls&sbbsetsubsetckrtafrcunebase-Ebbset.defaultbnsesubset.mcrtri冷(basesubsttLirtesubstituteDirectsub|Returnsubsetsofvectors,matri匚舌ordata
3、frames训hichmeetcondltiani.TPreeeFlforadditi-omlhmlpiCodecompletionalsoworksforfunctionarguments,soifyoutypedthefollowing:andthenpressedTab代码补全还可以对参数功能进行工作,如果你可输入subset(然后按,你*将看Tab到:检索以前命令当你使用R进行工作,你将经常可输入重新执行你之前输入的命令。与标准的R控制台一样,RStudio控制台支持使用以下方向键回忆之前命令的功能:ecallpreviouscommand(s)verseofUpIfyouwishmm
4、andsandthenselectacommandfromthislistyoucanuseiewtoreviewthelist(notethatontheMacyoucanalsouse如果你希望回顾你当前的命令列表并从中表(注意:在Mac你还可使用Lomsoe-.heaaCex.ainpleJsufflTiciryfexaTipLejexample-nnmesCexamplejYoucanalsousethissamekeyboardshortcuttoquicklysearchforcommandsthatmatchagivenprefix.ForYoucanalsousethissam
5、ekeyboardshortcuttoquicklysearchforcommandsthatmatchagivenprefix.Forexample,tosearchforpreviousinstancesoftheplotfunctionsimplytypeplotandthen你还可以使用同样的快捷键来快速查找匹配给定前缀的命令。例如,查找前面出现过的plot函数,先输入plot然后example,tosearchforpreviousinstancesoftheplotfunctionsimplytypeplotandthen你还可以使用同样的快捷键来快速查找匹配给定前缀的命令。例如,
6、查找plot函数,先输入plot然后找前面出现过的I+U这个截屏阐明了控制台标题栏的一些额外功能。Displayofthecurrentworkingdirectory.TheabilitytointerruptRduringalongcomputation.MinimizingandmaximizingtheConsoleinrelationtotheSourcepane(usingthebuttonsatthetop-rightorbydouble-clickingthetitlebar).显示当前工作目录;能够在一个长期的计算里中断R;最小化和最大化Console和Source窗口(使用
7、右上按钮或双击标题栏)d$hortConsolereports/aralysisJA除了上述的历史和代码补全快捷键外,还有很多其他快捷键可用,其中最为有用的快捷键包括r到SourceovefocustotheSourfocUslea|the.ooleYoucanfi耳器。焦到IonsEditorcutsintheKeyboardShortcutsarticle.你可从KeyboardShortcuts文中找到所有快捷键列表。编辑执行代码RStudio的souce编辑器包含各种提高效率的特征,包括语法高亮显示,代码自动补全,多文件编辑以及查找和替换。RStudioalsoenablesyouto
8、flexiblyexecuteRcodedirectlyfromthesourceeditor.FormanyRdevelopersthisrepresentstheirpreferredwayofworkingwithR.Byexecutingcommandsfromwithinthesourceeditorratherthantheconsoleitismucheasiertoreproducesequencesofcommandsaswellaspackagethemforre-useasafunction.ThesefeaturesaredescribedintheExecutingC
9、odesectionbelow.RStudio还可以使你直接通过source编辑器灵活地执行R代码。对于许多R开发者来说,这是他们使用R的首选方式。通过source编辑器执行命令相对于控制台来说更便于复制命令序列和将其做为再次使用的函数进行打包;这些特征将在后面的执行代码部分讲解。文件管理PpoighfghtindcRstudio支持语法高亮显示和其他以下类型文件RscriptsR脚本文件SweavedocumentsSweave文件Tex文件TeXdocumentsToopenanexistingfileyouuseeitherthemenu菜单或者allavailableastabstof
10、acilitatequickswitchingbetweenopenopenedfiles.你可通过快捷键)。documents.IfyouhavealargenumberofopendocumentsyoucanalsonavigatebetweenthemusingtheiconmenutoselectfromrecentlyIfyouopenseveralfileswithinRStudiotheya也可使用READMEPpinyo换。如果你thefullnameoftheobject.RStudio可以使用Tab键来支持代码自动补全onthetabbarorthe如果你通过有大量的打开
11、文件antypepacenuiHericrej通过标标来进行菜单项(你也可使fcodeusngthelistrinpollResults的对象,你可输入poll然后按键,RStudio将自动完成该对象的全名。homePrices.R15x5ubset(xp)subbasesubsetdef口ult:basesubset.matrixbasesubstitutemiseciihc-f-i+i曰rh卢4冲LReturnsubsetsofvectors,matricesordataframeswhichmeetconditions.D-Sotircesubse-t.data.tramebaseQ(T
12、opLeveliCodecompletionalsoworksintheconsole,andmoredetailsonusingitcanbefoundtheconsoleCodeCompletiondocumentation.代码补全同样在控制台中工作,具体用法可间控制台代码自动完成codeCompletion文档。Findandreplacecanbeopenedusingthe可使用快捷键来RStidiocanashortcutkeorfromthenuitem.开查WithintarerefWithffioeaectic|nIofcosnthesceeditorctsndautoFt
13、icaljyfonfertiti|to.te-usablncedbuMat脾theareconvertedintofunctionarguments:RStudio可以在source编辑器中分析一组选择的代码,并自动将其转化成再次使用的函数。任何选择中的“free变量(选择引用对象但不创建)将转化为函数参数。(你也可使用jhomePrices.R贰快捷键bs.opfion.Rx22-Sourceoniaw才干nu#price-ofcalloptioncLpg;-logCs/x)+(r+0.5*d.pos-d.pos/Csigma*(t.expd.negs*pntrtii(d.p&s)-x*&x
14、p(-iOGoToFuncdonDefinitionF2ExtractFunctiar*t?3U匚ammeni/Un-cornmentLinesReindentLines卸注释取消注释oicancomentandomtiese*ction*ofciteanalsodothird菜单项来对所选的整个代码进行注释或取你可使用使用菜单项来对所选的整个代码进行注释或取消注释(你也可使用快捷键)。QIhcmePriceE.R*xbs-.cption.ftx閃hemePrices.R*X眄bs-.option.ftx|_|LJSourceon5a.ve匚*超Sourcenames(honestsuitii
15、Hiity(homesS-prisuininary(homesSuge)GoToFunctionOefinitlonF2ExtractFunctionCammentUrkcommentLines黠fReindentLin皀百首行缩进#states-Ievels(hafliesEstate)菲avePricecommand.Alternatively,anycommentQTh-errwsilinewhichincludesatleastfourtrailingdashacodesection.Forexample,allofthefollowin-插入一个新的代码段你使用个破折号(-),等号(
16、=)或井号#SectionOne#SectionTwo#SectionThree#Notethatasillustratedabovethelinecanstartanynumberofpoundsigns(#)solongasitendswithfourormore-,=,or#characters.注意:如前所述,可输入超过4个或更多的数量的#号,-,=等。菜单命令和快捷键foldndnan以下菜单命令和快捷键可以对折叠区域和代码段进行操作:-E(NotethattheCollapsenestedregionswithinthesourcefile).rl+Shift+R(Cmd+Shif
17、t+RontheMac)rt-dctions|sJVoftheditermotfolOldableregions(ratherthanallofthe注意:CollapseAll命令折叠所有外层可折叠区域(而不是源文件中的所有嵌套区域)NalitiReIutedTooicsit制輛dExHutinPCW编辑和执行代导航代码nabapierfesourcecodewrittenbyothersonyourteamorwithinaajorproductiviaturesnbevigationthrouolissiitancementaxternPurcecockages.de.LearningS
18、eteruninihgabefde|stanHgofRStudio包括一些在R源代码中加速导航的功能。学习这些功能可以提高效率并帮助更好地理解你的团队中其他人所写的源代码,或者是外部程序包中的源代码。nstring.查找文件rectplahendinilesdialsallowsyognI给出一个特定目录,查找文件(Edit-FindinFiles)允许你对每个现白查找每一个文件。显示查找文件对话框,编辑菜单并选择查找文件:Youcanfurthercustomizeyoursearchwithregularexpressionsandfiltersforspecificfiletypes.Y
19、oursearchresultswilldisplayinthepaneadjacenttotheconsole.Foreachmatchingstring,thefollowingwillbedisplayed:你可以进一步通过正式表达式和特定文件类型来自定义你的搜索。你的搜索结果将显示在控制台的相邻窗口中。每一个匹配的字符串都将显示以下信息:Thefilepath文件路径Thelinenumberofeachoccurrence每个出现的行号Thematchingstring(highlighted),inthecontextofthecurrentline当前行内容中匹配的字符串(高亮)
20、Doubleclickingtheline,willopenthefileintheRStudiosourceeditor.ThekeyboardshortcutforFindinFilesis双fthesourcefihaan)eunctionsotusit如果你知道源文件或函数的名字并想对其进行编辑,你可以使用RStudio工具条中的GotoFile/Function搜索框迅速导航。乜jbackquote.R!SouronSavefibacksolve.RScLirceFilesrc/library/toPnrtoftheRpackznb日匚kSpline(src/librarv/spli
21、nes/Fl/splineClasses.RlbackSpline.nbSpline(sr匚斗567gThisprogrcunisfreitunderthetermstheFreeSoftwareF(tityouroption)nnCDbm匸kipline,npolySpline(srbm匚ksolve(5rc/librarY/ba5e/K/bHck5olve.K)backsaFve(src/library/methods/R/makeBasicFunsList.RJTheGotoFile/Functionfeatureworksoffaconstantlyupdatedindexofyour
22、sourcecode.Thespecificsourcefilestoindexaredeterminedasfollows:GotoFile/Function功能就不断更新索引你的源代码。专业源文件的索引将决定于:IfanRStudioProjectisactivethenallRsourcefileswithintheprojectdirectoryareindexed.IfaProjectisnotactivethenallcurrentlyopenRsourcefilesareindexed.I.RStudioProject是活动的,然后所有的R源文件在程序包列表中将被索引;2.如果一
23、个Project不活动,那么所有当前打开的R源程序将被索引;ThekeyboardshortcutforGotoFile/FunctionisGotoFile/Function的快捷键是转到函数定义rl+.Ctrl+.GotoFunctionSinceanindexofyourRsourcecode(asdescribedabove)ismaintained,RStudiocanalsohelpyouquicklynavigatetodefinitionofanyRfunction.Tonavigateafunctiondefinitionyouplaceyourcursoronthefunc
24、tionname(itdoesnthavetofullyselected)andthenchoosethecommand:当一个你的R源代码指数(如上所述)被维护,Rstudio也可帮助你迅速对任何R函数进行导航。你可将光标放在函数名称上(不需要完全选定)来导航函数定义,然后选择命令:Youcanalsoaccessgotofunctiondefinition:你也可这样去访问函数定义:使用Ctrl+Click鼠标点击thUsingouseFromUsingthekeyboardshortcut使用F2快捷键sole器或控制台Itispossibletonavigatetobothyourow
25、nfunctions(definedinRsourcefiles)aswellasanyotherfunctiondefinedwithinanRpackage.Forfunctionsdefinedwithinpackagesthecodeisdisplayedinaspecialewhichisread-only.Sourc(在R源文件中定义)和其他所有在R程序包中定义的函数。程序包中定义的函数,其代码将显示在特定的编辑,但可以复制粘贴出来使用。源文件导航窗口中,它仅能只读不能SourceViewThegotofunctiondefinitionfeaturedescribedabovea
26、lsoworksforfunctionswithinthecurrentsourcefile(givingtofunctionsdefinedwithinthecallingscope).precedenceThecommand(shortcut:)canbeuedtogotoanylineinthecurre|jThecommand(shortcut:)canbeusedtogotoanylineinthecurrentYoucanalsousethefunctionmenu(shownbelow)toquicklyjumptofunctionsbyname.上述的gotofunctiond
27、efinition功能同样可以对当前源文件的函数进行工作(在调用范围中给出函数定义优先级。Youcanalsousethefunctionmenu(shownbelow)toquicklyjumptofunctionsbyname.上述的gotofunctiondefinition功能同样可以对当前源文件的函数进行工作(在调用范围中给出函数定义优先级。命令(快捷键命令(快捷键)可用于转到当前文件的任意一行;)可用于转到当前文件的任意一行;9NotethatthefunctionmenucurrentlysupportsstandardRfunctionshoweverdoesnotyetsup
28、portS4methods.注意:当前函数菜单支持标准R函数,但是不支持S4方法。向前与向后dekltowaiouditiion.RSta(especiallyHhennavigatinga亠“0;offunction申Ils)youoftMofellVemtigWloinsandigallowsyoutotraversethemusingtheandcommands(availableontheEditmenuandonthefarleftofthesourceeditortoolbar).当代码导航(特别是在一系列函数中导航),你经常要快速返回之前编辑的位置。RStudio维护有一个活动的
29、导航列表,允许你使用Back和Forward命令(Edit菜单中或在source编辑条的最左边)进行来回遍历。Openingadocument(orswitchingtabs)打开一个文件(或切换标签)转到函数定义GoingtoafunctiondefinitionJumpingtoaline跳到一行JumpingtoafunctionusingthefunctionmenuYoucanalsoinvokeandusingtheCtrl+F9/Ctrl+F10(Cmd+F9/Cmd+F10ontheMac)keyboardshortcuts.你同样可以使用快捷键Ctrl+F9/Ctrl+F10
30、(Cmd+F9/Cmd+F10ontheMac)来调用Back和Forward:UsingProjects使用项目RStudioprojectsmakeitstraightforwardtodivideyourworkintomultiplecontexts,eachwiththeirownworkingdirectory,workspace,history,andsourcedocuments.RStudio项目直接让你的工作多语境,每一个自带工作目录、工作空间、历史和源文件。CreatingProjects创建项目RStudioprojectsareassociatedwithRworki
31、ngdirectories.YoucancreateanRStudioproject:RStudio项目与R工作目录相连,你可通过以下方式创建RStudio项目:InabrandnewdirectoryInanexistingdirectorywhereyoualreadyhaveRcodeanddataBycloningaversioncontrol(GitorSubversion)repository在全新的目录下;在现有的你已存放有R代码和数据的目录下;通过克隆一个版本控制(Git或Subversion)元数据库;TocreateanewprojectusetheNewProjectco
32、mmand(availableontheProjectsmenuando可使用创建NewProject命令(在Projects菜单中)一个新项目。UsingCommandHistory使用命令历史RStudiomaintainsadatabaseofallcommandswhichyouhaveeverenteredintotheConsole.YoucanbrowseandsearchthisdatabaseusingtheHistorypane.RStudio维护有所有你曾输入控制台的命令的数据库,你可使用历史窗口来浏览和搜索这个数据库。BrowsingHistory浏览历史Command
33、syouhavepreviouslyenteredintheRStudioconsolecanbebrowsedfromtheHistorytab.Thecommandsaredisplayedinorder(mostrecentatthebottom)andgroupedbyblockoftime:你之前输入RStudio控制台的命令可以通过历史标签进行浏览,这些命令将按顺序显示出来(最近的命令在底部)并按时间分组。WorkspaceHistory=n12-SendtoConsoleInsertintoSource1/1/117:38AM1ibrary(ggplcrtZ)auininary(
34、di口tnoiids)qplot(pricePcarat,data=diafiionds1/4/119:42ANmodel.1tlim=cplotCmpgan,ckrtci=urtccirs)1/3/H1:42PMplotCmpg-dispPita=mtcars)lf3fll1:41PMplot(x.-y+z)3:50AMplotCx-yS:47AM(ShowingCommandContext显示命令上下文Aftersearchingforacommandwithinyourhistoryyoumaywishtoviewtheothercommandsthatwereexecutedinpro
35、ximitytoit.Byclickingthearrowintherightmarginofthesearchresultsyoucanviewthecommandwithinitscontext:在你的历史中搜索完一个命令后,你可能希望看到与之接近的其他命令。点击搜索结果的右侧边缘的箭头,你将看到命令的上下文。UsingCommands使用命令CommandsselectedwithintheHistorypanecanbeusedintwofashions(correspondingtothetwobuttonsontheleftsideoftheHistorytoolbar):在历史窗
36、口中所选的命令可以通过两种方式进行使用(对应历史工具栏左侧的两个按钮):SendtoConsoleSendstheselectedcommand(s)totheConsole.NotethatthecommandsareinsertedintotheConsolehowevertheyarenotexecuteduntilyoupressEnter.ToConsole将所选命令发送到控制台。注意命令插入控制台后直到你按Enter键才会执行。InsertintoSourceInsertstheselectedcommand(s)intothecurrentlyactiveSourcedocume
37、nt.IfthereisntcurrentlyaSourcedocumentavailablethenanewuntitledonewillbecreated.ToSource将所选命令发送到当前活动的源文件。如果当前没有源文件则将创建一个新的未命名的源文件。Withinthehistorylistyoucanselectasinglecommandormultiplecommands:历史列表中,你可选择单个命令或者多个命令(按住Ctrl键不连续多选或按住Shift键选择连续的命令段):RelatedTopics相关主题WorkingintheConsole在控制台中工作Editingand
38、ExecutingCode编辑和执行代码WorkingDirectoriesandWorkspaces工作目录和工作空间ThedefaultbehaviorofRforthehandlingof.RDatafilesandworkspacesencouragesandfacilitatesamodelofbreakingworkcontextsintodistinctworkingdirectories.ThisarticledescribesthevariousfeaturesofRStudiowhichsupportthisworkflow.R对所操作的.RData文件和工作空间的默认行为
39、支持和推动将工作环境划分为不同目录的模型。本文阐述RStudio支持这种工作流程的多种功能,IMPORTANTNOTE:Inversionv0.95ofRStudioanewProjectsfeaturewasintroducedtomakemanagingmultipleworkingdirectoriesmorestraightforward.ThefeaturesdescribedbelowstillworkhoweverProjectsarenowtherecommendedmechanismfordealingwithmultipleworkcontexts.重要提示:在RStudi
40、ov0.95中,一个新的项目功能被引入进来以使得多个工作目录的管理更直接。以下阐述的功能仍然工作,尽管项目作为推荐机制来处理多个工作环境。DefaultWorkingDirectory默认工作目录AswiththestandardRGUI,RStudioemploysthenotionofaglobaldefaultworkingdirectory.Normallythisistheuserhomedirectory(typicallyreferencedusinginR).WhenRStudiostartsupitdoesthefollowing:与标准的RGUI一样,RStudi。采用全局
41、默认工作目录的概念。通常这是使用者的主目录(通常参考R中使用)。当RStudio开始他将如下操作:Executesthe.Rprofile(ifany)fromthedefaultworkingdirectory.Loadsthe.RDatafile(ifany)fromthedefaultworkingdirectoryintotheworkspace.PerformstheotheractionsdescribedinRStartup.运行默认工作目录下的.Rprofile;装载默认工作目录下的.RData文件到工作空间中;执行其他活动描述在RStartup中WhenRStudioexit
42、sandtherearechangestotheworkspace,apromptaskswhetherthesechangesshouldbesavedtothe.RDatafileinthecurrentworkingdirectory.当RStudio退出和工作空间发生变化,一个提示将问及是否保存这些改变到当前工作目录的.RData文件中。ThisdefaultbehaviorcanbecustomizedinthefollowingwaysusingtheRStudioOptionsdialog:可使用RStudioOptions对话框通过以下方式来自定义默认行为:Changethed
43、efaultworkingdirectoryEnable/disabletheloadingof.RDatafromthedefaultworkingdirectoryatstartupSpecifywhether.RDataisalwayssaved,neversaved,orpromptedforsaveatexit.改变默认工作目录;启用/禁用开始时从默认工作目录中装载.RData;指定.RData退出时是否总是保存、不保持或者提示保存。ChangingtheWorkingDirectory修改工作目录ThecurrentworkingdirectoryisdisplayedbyRStu
44、diowithinthetitleregionoftheConsole.Thereareanumberofwaystochangethecurrentworkingdirectory:当前的工作目录显示在RStudio控制台的标题区域。有多种方法可以改变当前工作目录:UsethesetwdRfunctionUsetheTools|ChangeWorkingDir.menu.ThiswillalsochangedirectorylocationoftheFilespane.FromwithintheFilespane,usetheMore|SetAsWorkingDirectorymenu.(N
45、avigationwithintheFilespanealonewillnotchangetheworkingdirectory.)使用R函数setwd;使用Tools|ChangeWorkingDir.菜单,他也将改变文件窗口的目录位置;从文件窗口中使用More|SetAsWorkingDirectory菜单。(在文件窗口中导航将不改变工作目录)Becarefultoconsiderthesideeffectsofchangingyourworkingdirectory:考虑改变你的工作目录请小心,它有以下副作用:Relativefilereferencesinyourcode(fordat
46、asets,sourcefiles,etc)willbecomeinvalidwhenyouchangeworkingdirectories.Thelocationwhere.RDataissavedatexitwillbechangedtothenewdirectory.应用你代码中的相关文件(如数据集、源文件等)将无效,当你改变工作文件;.RData退出时所保持的位置将改变到新目录中;Becausethesesideeffectscancauseconfusionanderrors,itsusuallybesttostartwithintheworkingdirectoryassociat
47、edwithyourprojectandremainthereforthedurationofyoursession.ThesectionbelowdescribeshowtosetRStudiosinitialworkingdirectory.因为这些副作用可能导致迷失和错误,最好是通常从与你项目相连的工作目录开始,并保持在那里进行你的操作。后文将阐述怎样设置RStudi。的初始工作目录。StartinginOtherWorkingDirectories开始其他工作目录Ifallofthefilesrelatedtoaprojectarecontainedwithinasingledirec
48、torythenyoulllikelywanttostartRStudiowithinthatdirectory.Thereareanumberofways(whichvarybyplatform)todothis.如果所有的文件与一个包含在单个目录下的项目相关,那么你最好从那个目录开始RStudio。有多种方式(平台不同将有所变化)来实现这个。FileAssociations文件关联OnallplatformsRStudioregistersitselfasahandlerfor.RData,.R,andotherRrelatedfiletypes.Thismeansthatthesyste
49、mfilebrowserscontext-menuwillshowRStudioasanOpenWithchoiceforthesefiles.RStudio的所有平台自己注册成一个处理程序如.RData,R和其他R相关文件类型。这意味着系统文件浏览器的上下文菜单将对在RStudio对这些文件进行开放选择。YoucanalsooptionallycreateadefaultassociationbetweenRStudioandthe.RDataand/or.Rfiletypes.你也可以有选择地创建RStudio和.RData或.R文件的默认关联。Whenlaunchedthroughafi
50、leassociation,RStudioautomaticallysetstheworkingdirectorytothedirectoryoftheopenedfile.NotethatRStudiocanalsoopenfilesviaassociationswhenitisalreadyrunninginthiscaseRStudiosimplyopensthefileanddoesnotchangetheworkingdirectory.当开始通过了一个文件关联,RStudio将自动设置工作目录到打开文件的目录。注意RStudio当它已经运行也可通过连接打开文件一一在这种情况下,RS
51、tudio仅打开文件,但不改变工作目录。Shortcuts(Windows)快捷键OnWindows,youcancreateashortcuttoRStudioandcustomizetheStartinfield.WhenlaunchedthroughthisshortcutRStudiowillstartupwithinthespecifiedworkingdirectory.在Windows中,你可创建一个RStudio快捷键来自定义“Startin部分。当启动这个RStudio快捷键,将通过特定工作目录来开始。DragandDrop(Mac)OnMac,dragginganddrop
52、pingafolderfromtheFinderontheRStudioDockiconwillcauseRStudiotostartupwiththedroppedfolderasthecurrentworkingdirectory.RunfromTerminal(MacandLinux)OnMacandLinuxsystemsyoucanrunRStudiofromaterminalandspecifywhichworkingdirectorytostartupwithin.Additionally,onLinuxsystemsifyourunRStudiofromaterminaland
53、specifynocommandlineargumentthenRStudiowillstartupusingthecurrentworkingdirectoryoftheterminal.Forexample,ontheMacyoucouldusethefollowingcommandstoopenRStudio(respectively)inthe/projects/foodirectoryorthecurrentworkingdirectory:$open-aRStudio/projects/foo$open-aRStudio.OnLinuxyouwouldusethefollowing
54、commands(notethatno.isnecessaryinthesecondinvocation):$rstudio/projects/foo$rstudioHandlingof.RprofileWhenstartingRStudioinanalternateworkingdirectorythe.Rprofilefilelocatedwithinthatdirectoryissourced.If(andonlyif)thereisnotan.Rprofilefileinthealternatedirectorythentheglobaldefaultprofile(e.g./.Rpr
55、ofile)issourcedinstead.LoadingandSavingWorkspaces装载和保存工作空间IfyouwanttosaveorloadaworkspaceduringanRStudiosessionyoucanusethefollowingcommandstosavetoorloadfromthe.RDatafileinthecurrentworkingdirectory:如果你想在RStudio回话过程中保存或装载工作空间,你可使用一下命令从当前工作目录下的.RData文件来进行保存和装载。save.image()load(.RData)Notethattheload
56、functionappends(andoverwrites)objectswithinthecurrentworkspaceratherthanreplacingitentirely.Priortoloadingyoumaythereforewishtoclearallobjectscurrentlywithintheworkspace.Youcandosousingthefollowingcommand:注意:load函数rm(list=ls()Notethatsinceloadingishandledatstartupandsavingishandledatexit,inmanycases
57、youwontrequirethesecommands.Ifhoweveryouchangeworkingdirectorieswithinasessionyoumayneedtheminordertosyncyourworkspacewiththedirectoryyouhavechanagedto.TheRStudioWorkspacemenualsoincludesitemsthatexecutetheabovedescribedcommands,aswellasenablesyoutoloadorsavespecific.RDatafiles.HandlingofRhistory处理.
58、RhistoryThe.RhistoryfiledetermineswhichcommandsareavailablebypressingtheuparrowkeywithintheconsoleBydefault,RStudiohandlestheRhistoryfiledifferentlythanthestandardRconsoleorGUI,howevercanbeconfiguredtoworkthesamewasasthoseenvironmentsifyouwishTheconventionalhandlingofRhistoryfilesisasfollows:Loadand
59、save.RhistorywithinthecurrentworkingdirectoryOnlysavethe.Rhistoryfilewhentheuserchoosestosavethe.RDatafileWhereasthedefaultRStudiohandlingof.Rhistoryfilesis:Loadandsaveasingleglobal.Rhistoryfile(locatedinthedefaultworkingdirectory)Alwayssavethe.Rhistoryfile(evenifthe.RDatafileisnotsaved)TheRStudiode
60、faultsareintendedtomakesurethatallcommandsenteredinprevioussessionsareavailablewhenyoustartanewRStudiosession.IfyouprefertheconventionalRtreatmentof.RhistoryfilesyoucancustomizethisbehaviorusingtheGeneralpaneloftheOptionsdialog.CustomizingRStudio自定义RStudioOverview概述RStudiooptionsareaccessiblefromthe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 黄酒酿造工岗中职业危害考核试卷含答案
- 中药材种植员岗前创新方法考核试卷含答案
- 天线线务员岗位考核试卷含答案
- 2026年鱼类行业洞察报告及未来五至十年发展趋势报告
- 2026年橡胶沥青行业洞察报告及未来五至十年发展趋势报告
- 2026年品牌策略研究论文题目及答案
- 安全知识类素材
- 2025-2026华东师大版初中八年级语文下学期期末卷
- 安全知识竞赛的
- 2026年七年级上册第6章 平面图形的初步认识 第1套 基础巩固
- 蜂王浆的课件
- 基于多因素协同的喷涂机器人喷枪轨迹优化策略与应用研究
- 药品qa培训课件
- 项目合作佣金协议书范本
- 农村土地承包合同书
- 艺术品交易市场建设合同
- UL1977标准中文版-2019连接器UL中文版标准
- 公共图书馆情绪疗愈空间设计研究:动因、现状与实现机制
- 肺部疾病护理查房
- 心理咨询中的认知重构技巧
- 第9章 语义分割
评论
0/150
提交评论