您好,欢迎访问三七文档
Rëëëkkk¡¡¡byTomShort,EPRIPEAC,tshort@epri-peac.com2004-10-21translatedbySZLiu,sunbjt@hotmail.com2006-09-22Grantedtothepublicdomain.See(withpermission).version1.02006-09-22¼¼¼ÏÏÏÜ©R¼êÑk3©help(topic)'utopic©.?topicÓþhelp.search(topic)|¢ÏXÚapropos(topic)£¤k3|¢´»e÷vKLª”topic”¤k鶡help.start()HTML/ªÏstr(a)w«RéS3á5(*str*ucture)½{`²ésummary(a)ÑaV,Ï~´5ÚOV; §kØÓÅnÚaá5ls()w«|¢´»eé;½pat=pat,Uª^|¢ls.str()str()|¢´»ezCþdir()3c8¹ew«©methods(a)w«a“S3methods”methods(class=class(a))L¤k±)ûáuéa{ÑÑÑ\\\ÑÑÑÑÑÑload()\1dsave·-ê|data(x)\1½ê|library(x)\1 ÷read.table(file)ÖLª©¿òÙMï¤êâµ;%@©Îsep=?¿whitespace;¦^header=TRUEÖ11IK;¦^as.is=TRUEiÎþCfactors;¦^comment.char=#)º5º;¦^skip=n3ÖêâcaLn1;[Ï'u1·¶,NA?n,ÚÙ¦read.csv(filename,header=TRUE)Óþ,%@ÖÏ:©©read.delim(filename,header=TRUE)Óþ,%@Ötab©©read.fwf(file,widths,header=FALSE,sep=,as.is=FALSE)±fixedwidthformatted/ªÖêâêâµ;widths´êþ,^uN°Ýiãsave(file,...)±Ø©²?½ésave.image(file)¤kécat(...,file=,sep=)r=ziÎ arguments;separgumentsm©iÎprint(a,...)w«arguments;5, §kØÓÅnÚaá5format(x,...)ªz,Ðw«Réwrite.table(x,file=,row.names=TRUE,col.names=TRUE,sep=)3rx=zêâµ ,©;XJquoteTRUE,iÎÚÏfÒ¬()¤;sep´iã© Î;eol1©Î;naiÎG;¦^col.names=NAO\IK±BuÚLÑ\sink(file)ÑÑ©file,Ñ\·-sink()Ü©I/O¼êÑkfileëê.§±´½¶¡½ëiÎG.file=¿XIOÑ\½ÑÑ.ë(Connections)±º©(file),+(pipes),Ø ©(zippedfiles)½RCþ.3windowsö¸e.©¦^±ÏLi(clipboard)ª.ÖExcelL,±òExcel¥êâi,¦^x-read.delim(clipboard)ªÖêâ.XJòêâ\iøExcel¦^,±¦^write.table(x,clipboard,sep=\t,col.names=NA)ê⥡pA^,RODBC,DBI,RMySQL,RPgSQL,andROracle÷.ÖÙ¦©ªëXML,hdf5,netCDF÷.êêêâââMMMïïïc(...)~òXëê=zþ¼ê;ÏLrecursive=TRUEüSüL¿|ܤkþ.from:to)S;“:”kp?O`k?;1:4+1“2,3,4,5”seq(from,to))Sby=½OÌ;length=½¦Ýseq(along=x)generates1,2,...,length(along);usefulforforloopsrep(x,times)Extimesg;¦^each=5Exeachg;rep(c(1,2,3),2)123123;rep(c(1,2,3),each=2)112233data.frame(...)Mïêâµ,CþU·¶½·¶;data.frame(v=1:4,ch=c(a,B,c,d),n=10);éáþ¬W¿þÝlist(...)MïdCþ|¤L,CþU·¶½·¶;list(a=c(1,2),b=hi,c=3i);array(x,dim=))dx|¤ê|;¦^aqdim=c(3,4,2)½ê;XJxØÝ,KxgÄÌmatrix(x,nrow=,ncol=)Ý;Óþfactor(x,levels=)rþx?è¤Ïf.gl(n,k,length=n*k,labels=1:n)ÏL½Y²ª)Y²(Ïf);kY²ê;nEgêexpand.grid()þÚÏf|ܤêâµrbind(...)r±1/ª|ÜÝ,êâµ,½Ù¦cbind(...)Óþ.±/ªêêêâââÚÚÚ©©©lllþIx[n]1nx[-n]Ø1nxx[1:n]cnx[-(1:n)]1n+1 x[c(1,4,2)]½x[name]¶namex[x3]¤ku3x[x3&x5]«m(3,5)x[x%in%c(a,and,the)]½|¥LIx[n]Lw«nx[[n]]L1nx[[name]]¶namex$nameÓþ.ÝIx[i,j]eI(i,j)x[i,]1i1x[,j]1jx[,c(1,3)]11Ú3x[name,]¶name1êâµI(ÝI\eã)x[[name]]¶namex$nameÓþ.CCCþþþCCCas.array(x),as.data.frame(x),as.numeric(x),as.logical(x),as.complex(x),as.character(x),...=Cþa.;¦^Xe·-ÜL,methods(as)CCCþþþ&&&EEEis.na(x),is.null(x),is.array(x),is.data.frame(x),is.numeric(x),is.complex(x),is.character(x),...uCþa.;¦^Xe·-ÜL,methods(is)length(x)x¥êdim(x)#½éê;dim(x)-c(3,2)dimnames(x)#½é¶¡nrow(x)1ê;NROW(x)^Ó,´§rþwü1Ýncol(x)ÚNCOL(x)Óþ.class(x)½xa;class(x)-myclassunclass(x)íØxaattr(x,which)½xá5a.whichattributes(obj)½objá5LêêêâââÀÀÀÚÚÚöööwhich.max(x)£x¥Iwhich.min(x)£x¥Irev(x)=x¥¤ksort(x),Süx¥;üSü¦^:rev(sort(x))cut(x,breaks)òx©¤Aã(½Ïf);breaksã꽩:þ.match(x,y)£ÚxÓÝ Úy¥þØK£NAwhich(x==a)XJ'öý(TRUE),£þx.choose(n,k)|ÜêOna.omit(x)Ø(NA)(Ø'1XJxݽêâµ)na.fail(x)£Ø&EXJx¹NAunique(x)XJxþ½êâµ,£table(x)£dxØÓê|¤L(~^uê½Ïf),=ªêLsubset(x,...)â^(...Àx¥,X:x$V110);XJxêâµ,Àselect¦^KÒÑ3½ØCþsample(x,size)Ø£Å3þx¥Äsize,Àreplace=TRUE#N£Äprop.table(x,margin=)âmargin¦^©êL«L,Ãmargin,¤kÚ1êêêÆÆÆ+,-,×,÷,ˆsin,cos,tan,asin,acos,atan,atan2,log,log10,expmax(x)£xmin(x)Óþ.range(x)£c(min(x),max(x))sum(x)x¥\Údiff(x)þx©prod(x)x¥ë¦mean(x)xþmedian(x)x¥ êquantile(x,probs=)÷v½VÇ© ê(%@0,.25,.75,1)weighted.mean(x,w)\²þrank(x)x¥var(x)orcov(x)þx;XJx´Ý½êâµ,ÝòOsd(x)xIO;sd(x)=sqrt(var(x))cor(x)XJx´Ý½êâµ,£'(1XJxþ)var(x,y)orcov(x,y)xÚym;XJx,yݽêâµ,£xÚycor(x,y)xÚy5'Xê;½ö',XJxÚyݽêâµround(x,n)xê,°(n log(x,base)Ox±baseÄéê,%@Äexp(1)scale(x)XJx´Ý,K¥%zÚIOzêâ;eIOzK¦^Àcenter=FALSE,e¥%z¦^scale=FALSE(%@center=TRUE,scale=TRUE)pmin(x,y,...)x[i],y[i]'ö,|¤#þpmax(x,y,...)Óþ.öcumsum(x)dx|¤þ,x[i]=sum{x[1]:x[i]}cumprod(x)Óþ.ë¦cummin(x)Óþ.cummax(x)Óþ.union(x,y),intersect(x,y),setdiff(x,y),setequal(x,y),is.element(el,set)“set”¼êRe(x)Eê¢ÜIm(x)JÜbcodeMod(x)ýé;Óabs(x)Arg(x)EêÝ(inradians)Conj(x)complexconjugateconvolve(x,y)computetheseveralkindsofconvolutionsoftwose-quencesfft(x)FastFourierTransformofanarraymvfft(x)FFTofeachcolumnofamatrixfilter(x,filter)applieslinearfilteringtoaunivariatetimeseriesortoeachseriesseparatelyofamultivariatetimeseriesõê
本文标题:R常用函数整理
链接地址:https://www.777doc.com/doc-5475110 .html