An-ABC-introduction-to-R

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

R:Statistics?Programme?andWhoareYou?--AnABCintroductiontoRPresentedbyGuohuiDingR&D,SIBS,CASForFudanUniversityMainTopicsToday•WhatisR?•HowtoadministrateR?•HowdoesRwork?•HowtoapplyRforstatisticalproblem?•HowtoprogramyourRfunction?•………WhatisR?AbriefhistoryofRThelegendofR•Rstartedintheearly1990’sasaprojectbyRossIhakaandRobertGentlemanattheUniversityofAuckland,NewZealand,intendedtoprovideastatisticalenvironmentintheirteachinglab.ThelabhadMacintoshcomputers,forwhichnosuitablecommercialenvironmentwasavailable.RobertGentlemanRossIhakaR’sParents(1)•TheSlanguage–S:aninteractiveenvironmentfordataanalysisdevelopedatBellLaboratoriessince1976–ExclusivelylicensedbyAT&T/LucenttoInsightfulCorporation,SeattleWA.Productname:“S-plus”.Youcanlearnmorefrom:“R”?•TheSchemelanguageSchemeisastaticallyscopedandproperlytail-recursivedialectoftheLispprogramminglanguageinventedbyGuyLewisSteeleJr.andGeraldJaySussman.Learnmore:•Scheme’sunderlyingsemantics+S’syntax=RR’sParents(2)“WehavenamedourlanguageR–inparttoacknowledgetheinfluenceofSandinparttocelebrateourownefforts.”--R.IhakaR.Gentleman--IhakaR.&GentlemanR.,1996RNow•Sincemid-1997therehasbeenacoregroupwhocanmodifytheRsourcecodeCVSarchive.•TheRpackagesystemCRAN(theComprehensiveRArchiveNetwork)•Ris“GNUS”—Alanguageandenvironmentfordatamanipula-tion,calculationandgraphicaldisplay.–ThatisRisaFreeSoftware(orOpensourcesoftware).(Here,Freereferstofreedom,notprice,althoughRisfreeinthatsenseaswell.)•ThecoreofRisaninterpretedcomputerlanguage.–Amosaicofprocedure-basedprogrammingandobject-orientedprogramming–GoodinterfacetoprocedureswritteninC,C++,FORTRANandotherlanguages–Aflexibledataexchangemechanismaccessingrelationaldatabases-ODBC,PostgreSQL,MySQLandsoon.——小偷与强盗的谈判RandStatistics•Mostpackagesdealwithstatisticsanddataanalysis.•Powerfulstatisticalgraphics.•Wellcrosstalkingwithotherstatisticalsoftwares.•MostRuserarestatisticalexperts.Youcanlearnmoremodernanalysismethodfromtheybyemail.•Youcandoitwhenyoucomeacrossathingnobodydoitbefore.InstallandadministrateRFocusonWindows(MS)HowdoIgetR?•Theinformationalwebsite•CRAN-theComprehensiveRArchiveNetwork.–Theprimarysiteis–CRANsiteshavebinarydistributionsforWindows95,98,ME,NT4,2000andXPonIntel,fortheMacintosh(System8.6to9.1andMacOSX),andforseveralLinuxdistributions.•Newreleasesoccurfrequently–aboutevery3months.Bepreparedtore-installfrequently.•Alsoyoucangetitfromyourfriends,teachers,etc.Downit!Itisabout20.6Minsize.UsingPrecompiledBinaryDistributionsInstallingR•Doubleclick“rw1091.exe”usingyourmouse.ThatisOK.YoucaninstallitasallotherstandardMSsoftwares.RConsole/RGuiinWindows(MS)CommandboxGraphicsboxMenuIconsSeveralconceptsinAdministratingR•Workspace–xxx.RData•History–xxx.Rhistory•Package•Object•Session•ConsoleRunyourRcodesLoad/saveworkspaceLoad/saveHistoryChangeyourworkingdirectory--IhakaR.&GentlemanR.,1996Addanewpackage•Commands:–library()addapackageinthelibrary–detach(package:xxx)detachapackage•AllcandointheGUI(exceptdetach())LoadalocalpackageInstallpackagesfrominternetorlocalUpdatethelocalpackagefrominternetPackagesinREnvironment•Basicpackages–package:methodspackage:statspackage:graphics“package:utilspackage:base•Recommandedpackages–grid;lattice;e1071…•Contributedpackages(morethan366packagesnowadays)–……Youcanseewhatpackagesloadednowbythecommandsearch().Don’tloseyourway!•Threeusefulsystemcommand–getwd()GetWorkingDirectory–setwd()SetWorkingDirectory–list.files()ListtheFilesinaDirectory/FolderShowtheDemonstrationsofthePackages/Functions•Commands–demo()DemonstrationsofRFunctionality–example()RunanExamplesSectionfromtheOnlineHelpGettingHelps•Severalcommands–help.start()–help()or?()–help.search()–apropos()•Internetsearching–Ilikeitverymuch.Itseemsomnipotence.QuitR•Command–q()TerminateanRSessionHowdoesRwork?BasicRStructureanddatamanipulationBasicRworkingflow(Objectorientation)package--RforBeginners.EmmanuelParadisObjectorientation•Object:acollectionofatomicvariablesand/orotherobjectsthatbelongtogether•Parlance:–class:the“abstract”definitionofit–object:aconcreteinstance–method:otherwordfor‘function’–slot:acomponentofanobjectTypesofDatainR•Thebasicdataobjectisavectorofelementsoftype:–numericnumbers-eitherfloatingpointorinteger–charactereachelementisacharacterstring–logicaleachelementisTRUEorFALSE–listelementscanbeanytypeofobject,includingotherlists•ComponentsoftheSlanguage,suchasfunctions,arealsovectors.•AnyvectorcanincludethemissingdatamarkerNAasanelement.•Allvectorshavealengthandamode.Thefunctionslengthandmodereturnthisinformationasdoesthestrfunction.•Astructureconsistsofadataobjectplusadditionalinformation.Matrices(orarrays,ingeneral)andtimeseriesareexamplesofstructures.OperatorsVectors,MatricesandArrays•Command:–array(data=NA,dim=length(data),dimnames=NULL)–matrix(data=NA,nrow=1,ncol=1,byrow=

1 / 51
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功