RforBeginnersChineseEdition2.0EmmanuelParadisInstitutdesSciencesdel'¶EvolutionUniversit¶eMontpellierIIF-34095Montpellierc¶edex05FranceE-mail:paradis@isem.univ-montp2.frCo-translatedby:XFWang,YHXie,JTLiandGHDing\RforbeginnersR20022005EmmanuelParadisLATEXChap1{2:Chap3:Chap4:Chap5{7:Rpwxf@hotmail.com20064c°2002,2005,EmmanuelParadisPermissionisgrantedtomakeanddistributecopies,eitherinpartorinfullandinanylanguage,ofthisdocumentonanysupportprovidedtheabovecopyrightnoticeisincludedinallcopies.Permissionisgrantedtotranslatethisdocument,eitherinpartorinfull,inanylanguageprovidedtheabovecopyrightnoticeisincluded.11232.1..............................32.2.....................52.3..............................73R93.1.................................93.2.........................113.3..............................143.4..............................153.4.1..........................153.4.2..........................183.5..............................193.5.1..........................193.5.2......................243.5.3............................263.5.4.............273.5.5......................303.5.6.........................323.5.7................323.5.8..........................344R374.1..............................374.1.1.....................374.1.2.........................384.2..............................414.3............................424.4..............................444.5..............................454.6gridlattice..........................495R565.1...................565.2.................................585.3..............................595.4..................................626R656.1............................656.2R..............................676.3.........................687R721R.RRRRossIhakaRobertGentleman1RAT&TS1RSInsightful2S-PLUSRSIhaka&Gentleman(1996)R-FAQ3RRGNUGeneralPublicLicence4RRDevelopmentCoreTeamRUnixLinux(CFortran)Windows,LinuxMacintoshComprehensiveRArchiveNetwork(CRAN)5LinuxLinuxCRANR(jpg,png,bmp,ps,pdf,emf,pictex,x¯g;)(P-)RRS6,RRRR\object1IhakaR.&GentlemanR.1996.R:alanguagefordataanalysisandgraphics.JournalofComputationalandGraphicalStatistics5:299{314.2://cran.r-project.org/doc/FAQ/R-FAQ.html4Formoreinformation:://cran.r-project.org/6Forexample:`'WindowsRgui.exe(...)RR(\assign)(object).R2.1RR(CFortan,Pascal,...)Rlm(y~x)\xyR(,ls())R(object)R(objects)()()(p.26).Rarguments¡!options¡!functiondefaultarguments=)result(argument)(...)R3RR(p.68)R,(Fig.1)()functionsandoperators?\dataobjects?6³³³³)XXXXXXXz\resultsobjects.../library/base//stast//graphics/...libraryoffunctions¾data¯les¾-internet¾PSJPEG...keyboardmouse-commandsscreenActivememoryHarddisk1:R.R(library),RHOME/library(RHOMER)(packages)baseRRR(baseRHOME/library/base/R/base)Rn10n[1]101n4print,print(n)(print)(A{Za{z),(0{9)(.)().RxX(Windows)2.2R(\assign):n-15n[1]155-nn[1]5x-1X-10x[1]1X[1]10()Rn-10+2n[1]12n-3+rnorm(1)n[1]2.208807rnorm(1)01(p.18):5(10+2)*5[1]60ls:name-Carmen;n1-10;n2-100;m-0.5ls()[1]mn1n2nameRpattern(pat)):ls(pat=m)[1]mname:ls(pat=^m)[1]mls.str():ls.str()m:num0.5n1:num10n2:num100name:chrCarmenpatternls.strmax.level,ls.strmax.level=-1M-data.frame(n1,n2,m)ls.str(pat=M)M:`data.frame':1obs.of3variables:$n1:num10$n2:num100$m:num0.5ls.str(pat=M,max.level=-1)M:`data.frame':1obs.of3variables:rm:rm(x)x,rm(x,y)xyrm(list=ls()).ls()rm:rm(list=ls(pat=^m))62.3R?lmlm()()help(lm)help(lm)?*Error:syntaxerrorhelp(*)Arithmeticpackage:baseRDocumentationArithmeticOperators...()(package)Description:briefdescription.Usage:forafunction,givesthenamewithallitsargumentsandthepossibleoptions(withthecorrespondingdefaultvalues);foranoperatorgivesthetypicaluse.Arguments:forafunction,detailseachofitsarguments.Details:detaileddescription.Value:ifapplicable,thetypeofobjectreturnedbythefunctionortheoper-ator.SeeAlso:otherhelppagescloseorsimilartothepresentone.Examples:someexampleswhichcangenerallybeexecutedwithoutopeningthehelpwiththefunctionexample.ExamplesArgumentsNote,ReferencesAuthor(s)helptry.all.packageFALSE,TRUE7help(bs)Nodocumentationfor'bs'inspecifiedpackagesandlibraries:youcouldtry'help.search(bs)'help(bs,try.all.packages=TRUE)Helpfortopic'bs'isnotinanyloadedpackagebutcanbefoundinthefollowingpackages:PackageLibrarysplines/usr/lib/R/librarybspackage:help(bs,package=splines)bspackage:splinesRDocumentationB-SplineBasisforPolynomialSplinesDescription:GeneratetheB-splinebasismatrixforapolynomialspline....Htmlhelp.start()htmlSeeAlsoRhelp.searchhelp.search(tree)\treehelp.searchrebuild(e.g.,help.search(tree,rebuild=TRUE))aproposapropos(help)[1]help.helpForCallhelp.search[4]help.start83R3.1Rf1,2,3gR7(FALSETRUE)modelengthx-1mode(x)[1]numericlength(x)[1]1A-Gomphotherium;compar-TRUE;z-1imode(A);mode(compar);mode(z)[1]character[1]logical[1]complexNA()N-2.1e23N[1]2.1e+23RInf-Inf§1NaN()79x-5/0x[1]Infexp(x)[1]Infexp(-x)[1]0x-x[1]NaNnncatwrite.table(p.14,qmethod)x-Doublequotes\delimitateR'sstrings.