您好,欢迎访问三七文档
RRfrequentlyaskedquestions://cran.r-project.org/mirrors.htmlUCBerkeleyRLinuxMacOSXWindowsWindowsWindows(95andlater)baseR-x.x.x-win32.exe3.RRR(RobertGentlemanRossIhaka)SS4.CRANCRANComprehensiveRArchiveNetworkR5.RR:AProgrammingEnvironmentforDataAnalysisandGraphics|RichardA.BeckerJohnM.ChambersAllanR.WilksAHandbookofStatisticalAnalysisUsingRBrianS.EverittTorstenHothornDataAnalysisandGraphicsusingRMaindonaldandBraunIntroductoryStatisticswithRDalgaard8.R2RR9.R1001001x¡rnorm(100,mean=5,sd=0.1)mean(x)3sd(x)summary(x)demo()Rdemo(graphics)10.RRGNUGeneralPublicLicense(GPL)11.R50%CPUWindowsCPUCPUR2CPUCPU50%12.RLATEXRcitation()BibTEX1citation(package=’package’)xB13.R\?topichelp(topic)topichelp.search(topic)apropos(tab)tabRSiteSearch()14.R3RR²RRCMDRterm1r¡¡max¡mem¡size=1GbRHOME/bin\21rgui¡¡max¡mem¡size=1Gb²Rmemory.limitRR32Mb3GbWindows2GbR32Mb2Gb15.help.search()JavaJavaJavascript16.RR17.RTabcompletion2.5.0RTabRTab18.rm()1rm(list=ls(all=TRUE))19.options(digits=)digits1227options(prompt)(show.error.messages)20.system()shell.exec():1#gotothecransystem(paste(’C:/ProgramFiles/InternetExplorer/iexplore.exe’,2Rterm43’cran.r-project.org’),wait=FALSE)#invokethenotepad5system(notepad)shell.exec(C:/WINDOWS/clock)21.WindowsRpackagesRlibrarylibraryupdate.packages()RRupdate.packages()22.packagesremove.packages(c(pkg1,pkg2),2lib=file.path(path,to,library))23.RWindowsXPRC:nDocumentsandSettingsnusernamegetwd()R(WorkingDirectory)setwd()24.save.image()Rworkingspace.RDatasave(...,¯le=)R25.RR326.library()R1detach(package:pkg)27.LibraryPackageRPackageLibraryLibraryPackagePackageLibraryWindows\*.zip28.Package3RUnixMacWindows5search()1.packages(all.available=TRUE)RRPackageRstatsgraphicsgrDevicesgridutilsRdatasetsmethodsRbase29.RRdatasets100data()1dim(data()$results)data()$results[,4]30.RRSclass1charactor2numeric3integer4logicalTRUE=TFALSE=F5complexa6listS7factora15\RSEverythinginSisanobject;EveryobjectisShasaclass.31.dataframe6dataframematrix-like32.RdistGenericFunctionmethods()4|1summary#Itisagenericfuncitonmethods(summary)#listoftheS3methods3summary.lm#maybeyouwanttoknowthelinearmodels'ssummary*.tar.gzR-2.5.1.tar.gz33.head()tail()1head(CO2)carsome34.Rlmglmy~modelymodelmodel+:\+:¤0a+b+a:b0(a+b+c)^2(a+b+c)¤(a+b+c)abc¡(a+b+c)^2¡a:b0a+b+c+b:c+a:c00log(y)a+log(x)0.update\1fm¡aov(Speed~Run+Expt)fm0¡update(fm,.~.¡Run)Hlatticej\35.R1e10==1000000000021.2e¡4==0.000124getAnywhere()7xC36.RforeignMinitab,S,SAS,SPSS,Stata,Systat,dBase37.RExcelExcelExcelExcel1.Excelcsv(CommaSeparatedValues)read.csv()2.RODBCodbcConnectExcel()xlslibrary(RODBC)2z¡odbcConnectExcel(rexceltest.xls)dd¡sqlFetch(z,Sheet1)4close(z)RDataImport/Export3.xlsReadWriteread.xls38.Rsink()data(CO2)2sink(CO2.txt)CO24sink()#gotoyourworkdirectory,youwillgetCO2.txt39.RRcapture.output()Rglmout¡capture.output(example(glm))2glmout[1:5]GotoLATEX!40.Rdata¡read.table(clipboard)2write.table(clipboard)841.(factor)fas.numeric(as.character(f))2#oras.numeric(levels(f))[as.integer(f)]42.Redit()¯x()1data¡data.frame()edit(x);fix(x)43.source()print()source(¯le,echo=TRUE)Rsink()source(¯le,echo=TRUE)sink44.RTEXHmisclatex()xtablextable()a¡matrix(1:6,nr=1)#require(xtable)2colnames(a)¡paste(col,1:6)xtable(a)xtable()HTMLRwordpowerpointLATEXquantreglatex.table()45.R1d:nnR¡2.4.1nnlibrarynnxgobinnscriptsnnxgobi.batd:/R¡2.4.1/library/xgobi/scripts/xgobi.bat¯le.choose()Windowschoose.dir()Windows,46.RSQLRSQLOracleMicrosoftSQLServerIBMDB2GNUGeneralPublicLicense(GPL)MySQL9RMySQL5MySQLRODBC|ODBCRlibrary(RODBC)2ch¡odbcConnect(stocksDSN,uid=myuser,pwd=mypassword)stocks¡sqlQuery(ch,select¤fromquotes)4odbcClose(ch)WindowsMicrosoftSQLServerAccessOracleMySQLPostgreSQLLinuxMySQLOraclePostgreSQLSQLiteR-dataxD47.RNAnotavailableRSNA6x¡NA2x3class(x)1x==NAis.na()1x[!is.na(x)]48.eval()parse()parse()expressioneval()1x¡1:10a¡print(x)3class(a)eval(parse(text=a))49.append()5DBI6RTRUEFALSENA10x¡1:52(foo¡c(x[1],0,x[2:5]))#expectedresultappend(x,0,after=1)50.()subset(select=)1x¡data.frame(matrix(1:30,nrow=5,byrow=T))dim(x)3print(x)new.x1¡x[¡c(1,4),]#row5new.x2¡x[,¡c[2,3]]#colnew.x1;new.x2subsetiS¡iris$Species==setosa2iris[iS,c(1,3)]subset(iris,select=c(Sepal.Length,Petal.Length),Species==setosa)51.1a1¡data.frame(num=1:8,lib=letters[1:8])a2¡a13a2[[3,1]]¡2¡a2[[8,2]]any(a1!=a2)#all(a1==a2)any()a1!=a2TRUEany()TRUEidentical()1indentical(a1,a2)1which(a1!=a2,arr.ind=TRUE)arr.indarrayindices52.uniqueunique111x¡c(9:20,1:5,3:7,0:8)(xu¡x[!duplicated(x)])3unique(x)#ismor
本文标题:153分钟学会R
链接地址:https://www.777doc.com/doc-4393491 .html