生物信息学资料-r相关liu-r-refcard_W_第1页
生物信息学资料-r相关liu-r-refcard_W_第2页
生物信息学资料-r相关liu-r-refcard_W_第3页
生物信息学资料-r相关liu-r-refcard_W_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、R ? k?=? ?d Tom Short tshorteprisolutions. com , 3www.R ? ?#? .? ? (? ?u?N?) ( ? ?aq,?V eZ?-.Y?9?od 4g) KI,Xk1?X: ,? ? 1.1 2007-1-23?:?R ?k3? help(topic) utopic ? .?topic ?help.search(topic) |?X?apropos(topic) ?k3|?e?v KL?”topic”?k?help.start() HTML/? ?demo R ?U?

2、 example(f)$13? fstr(a) w?R ? S3?5(*str*ucture)?summary(a) ?a V?, ?5?OV?;?5 a k? ?.ls() w?|?e ?; ?pat=pat?,U? ?|?ls.str() str() |?e z?C?dir() 3 c 8?ew?list.files() ?getwd() ? ?&Esetwd() ?&Emethods(a) w?a “S3 methods”methods(class=class(a) L?k?)?u?a ?options(.) ?u ?; ?k: width, digits, errorlibrary(x

3、) 1?(package); library(help=x)w?x ?datasets .require(x) ?attach(x) ?x?R |?; x ? L,?,?dsaveM? R data file. ?search()5w?|?. detach(x)attach_L?. assign(x,value) ?valueD?x,=”f?L/? ?6?scan(x) l? ? ? Lread.table(file) ? L? ? M?;% ? ?sep=?whitespace;?header=TRUE ?1? 1 ? I K;? as.is=TRUE? i ? ? C ?factors;?

4、comment.char=?# )?5?; ?skip=n 3?caLn 1;?u1?,NA ?n,?read.csv(filename,header=TRUE)?, % ? ?:? ?read.delim(filename,header=TRUE) ? ?,% ? ? ?tab ? ?read.fwf(file,widths,header=F,sep=t,as.is=FALSE)?f ixed width f ormatted/? ?; widths ? ?, u ?N ?i? save(file,.) ? ? ? ? save.image(file) ?k ? dump(x,.) ? x

5、3”.”pcat(., file=, sep= ) r?=z?i? ?arguments; sep ?argumentsm ? i?print(a, .) w?arguments; ? ,?u? ?k? L?.format(x,.) ?z,? w?R ?write.table(x,file=,s= T ,s= T , sep=) 3rx=z? , ?; XJquote ?TRUE, i?f ? ()?; sep ?i?; eol ?1? ?; na ?i?G; ?s=NA O IK? Bu?L?sink(file) ? ?file, ? ?-si

6、nk()? I/O ?kfile ?.?i?G5? . file= ?XIO?. ? (Connections)?(file),+ (pipes),?(zipped files)? R C?.3 windows ?e.? ?L i?(clipboard) ?.? Excel L,? Excel ? ? i?,?x 3?k?u3 ?xx 3 & x 5?m(3,5) ?xx %in% c(a,and,the) ?|? L?xnLw? ?nxnL 1n? ?xname ?name ?x$name?.? ?xi,jeI?(i,j)?xi,1i1x,j1j x,c(1,3)11?3xname, ?na

7、me 1?(? ?e?)xname ?name x$name?.C?C?as.array(x), as.data.frame(x), as.numeric(x), as.logical(x), plex(x), as.character(x), ,=?C?a.; ?Xe?-? L, methods(as)C?&Eis.na(x), is.null(x), is.array(x), is.data.frame(x),is.numeric(x), plex(x), is.character(x), .u C?a.; ?Xe?-? L, methods(is)length(x

8、) x ? ? ?dim(x) ?# ? ? ?; dim(x) - c(3,2)dimnames(x) ?# ? ? ?nrow(x) 1 ?; NROW(x)?,?r?w?1?ncol(x) ?NCOL(x) ?.class(x) ? ?x a;class(x) -myclassunclass(x) ?x anames(x) w? ?(names)unname(x) ? R ? ?(names)?(dimnames)unlist(x) ? L x =z? attr(x,which)? ?x ?5a.which attributes(obj) ? ?obj ?5 L?J?which.max(

9、x) ?x? ? ?which.min(x) ?x? ? ?rev(x) 6 x ?k ?rle(x) ?i?(Runs)&Esort(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) |?=n!/(n k)!k!sign?C?u0,?u?/10, u?/-10, u?/00na.omit(x) ?(NA)( ?1XJx ? ?)na.fail(x) ?&EXJx? ?NAu

10、nique(x) XJx?,?duplicated(x) ?x ?E ? ?6?table(x) ?dx ?|? L?(u ?f),=?Lsubset(x, .) ?(.? x? ?,X:x$V1 10); XJx?,?select?L?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,log

11、10,exp max(x) ?x?min(x)?.? range(x) ?c(min(x), max(x) sum(x) x? ? ?diff(x) ?x?prod(x) x? ?mean(x) x ?abs(x) x ?sqrt(x) x0.5median(x) x ?quantile(x,probs=) ?v?V?(%?0,.25,.75,1)IQR(x) O?m50% ?weighted.mean(x, w) ?rank(x) x? ? ?var(x) or cov(x) ?x ? ; XJx? ?, ? ? O?sd(x) x IO ; sd(x)=sqrt(var(x)cor(x)

12、XJx? ?,? (1 XJx?)var(x, y) or cov(x, y)x?ym ? ; XJx,y? ?,?x?y? ?cor(x, y) x?y?5?X?;? ,XJx?y? ?round(x, n) x ?,?( n?log(x, base) O?x?base? ?,%?exp(1)scale(x) XJx ? ,K?% z? IOz?;e? IOz K?center=FALSE, e?% z?scale=FALSE(% center=TRUE, scale=TRUE)integrate(f,lower,upper) ? f 3?m(lower,upper) ?(?)pmin(x,

13、y,.) xi, yi?,|?# ?pmax(x,y,.) ?. ?cumsum(x) dx|? ?,xi=sum x1:xi cumprod(x) ?.?cummin(x) ?.?cummax(x) ?.? union(x,y) x yx y intersect(x,y) x y setdiff(x,y) x xysetequal(x,y) ? x, y ? ?6?(x,y? 9S).is.element(el,set) ?x %in% yRe(x) E? ?Im(x) J?Mod(x) ?( );?abs(x) Arg(x)E? ?(in radians) Conj(x) ? x ?E?

14、convolve(x,y) O?S?fft(x) ? (array) ?F?C?mvfft(x) ? ? ?F?C?filter(x,filter) ? C?mS ?C?mS ?S?1?5L?6?na.rm=FALSE5?(NA).?t(x) =?diag(x) ?%*% ? $?solve(a,b) $?a %*% x = b xsolve(a) ? _rowsum(x) ? ?1?; rowSums(x) ? ?colsum(x), colSums(x) ?. rowMeans(x) 1? colMeans(x)?dist(x) O? x 1m ?lp?napply(X,INDEX,FUN

15、=) ?| eI(INDEX) A?FUN ?,?|? L ?lapply(X,FUN) AFUN LX z? ?tapply(X,INDEX,FUN=) ?x ?(INDEX) ? (ragged)? AFUNsapply ?lapply,?l?by(data,INDEX,FUN)A?FUN?n?data?dINDEX?f8merge(a,b) ? k ?1?r?xtabs(a b,data=x) l?a?f?Laggregate(x,by,FUN) ?x ? ?A?f8, ?O?f8 V?O, ? ?(J; by?| ? Lstack(x, .) ?m /? ? L? ?C?=z?unst

16、ack(x, .) stack() _L?reshape(x,.)?wide?long?1UE. wide?OC?*?long?OC?p?*?. ?(direction=”wide”)?(direction=”long”) ?.expression(expr) M?u ?L?(expression)/?.? is.expression(x), as.expression(x, .)parse(file = , n = NULL) ? L/?)?L,vk?LO? L?(expression)eval(expr) 3? ?eO? R L?(expression)i?paste(.) =z?i? ?

17、 ?;sep= ? .?(?%); ?Jcollapse= ? “collapsed”(Jsubstr(x,start,stop) J i? fi?;? ?D?,?substr(x, start, stop) ),seq() ?difftime() k.Date ?+?.?DateTimeClasses? &E.?chron?.as.Date(s)?as.POSIXct(s)=z?g?5;format(dt)=z?i?L?.% i?“2006-07-24”.? ?g?L?5?=z ?.? ? ?:%a, %A ?“(?U”(weekday)?%b, %B ? ?%d? F?(0131).%H

18、?(0023).%I ?(0112).%j c? F?(001366).%m ?(0112).%M ?(0059).%pAM/PM ?.%S ? ?(0061).%U (?(0053);1?(?U?1?(? 1?U.%w (?U?(06,?F?0).%W ?(0053);1?1?(? 1?U.%y ?V c(0099).?.%Y k?V c.%z (?.)? %?;-0800? %? 8 ?.%Z (?.)?i?G(? ?).weekdays(x) ?F?x “(?A” months(x) ?F?x ? quarters(x) ?F?x G!(Q1 - Q4)3?- ,w?ic3 ?K, ?J

19、5 ?.?strftime.?/C?(Graphics Devices)x11(), windows() ?m?I? dev.list() ?/I? Ldev.set() ?/I?plot.new() ?#?/(? c?/I?postscript(file) ? M ? PostScript ? / m ? ? / C ? ?; ? horizontal = FALSE, onefile =FALSE, paper = special ?EPS ?; family=?i N(AvantGarde, Bookman, Courier, Helvetica, Helvetica-Narrow, N

20、ewCentu- rySchoolbook, Palatino, Times, or ComputerModern); width=?height=?inches ? ; paper=?a.ps.options() 9?, ? w(XJvk?)postscript? ?pdf, png, jpeg, bitmap, xfig, pictex; ?w?Devicesdev.off() 4 ? ?(% c)? / C ?;? ? ? ? dev.cur, dev.set?plot(x) 3x?g/?x?(y?)plot(x, y) VC?(?:?)hist(x) x ?e? ?u? add=FAL

21、SEXJTRUE,3c?(XJ3)V?axes=TRUE XJFALSE,?I?ftype=p ? a.,p: :,l: ?,b ?:, o:?. ?BL:,h: R? ?, s:F, ?dR?L, S: F, ?dR? .?Lxlim=, ylim= ?I? ? ?xlab=, ylab= 5?I?main= ?IKsub= BIK( ?iN)$Y?-points(x, y) V:(?type=?)lines(x, y) ?. ?text(x, y, labels, .) 3?I:(x, y) ?i;. ?:plot(x, y, type=n); text(x, y, names)mtext

22、(text, side=3, line=0, .) 3 ? ?sideV ?font ? iN?(1:, 2:N, 3: oN, 4:oN); ?font.axis, font.lab, font.main, font.sublas ?I?iIP?(0: ?1u?, 1: ?, 2: R?u?, 3: ?)lty ? a., ? ?i?(1: solid, 2: dashed, 3:dotted, 4: dotdash, 5: longdash, 6: twodash),?L8?i? i?G(0?9m ?) O?x ?),?(”points”)?,Xlty=44?lty=2?lwd ? ?i,

23、%1mar ?/? k4? ?c(bottom, left, top, right),%?c(5.1, 4.1, 4.1, 2.1)mex (?/?N? i?NC?5?UCiN ? mfcol c(nr,nc) ? ?I?nr 1?nc ,U ?fI?mfrow ?. U1?fI?pch ? a.,?d1 ?25?,? p ?i?1 2345678910 11 1213 14 15barplot(x) x ? .?;?horiz=FALSEUC?Y?R?i(? axis); line?V?i ?16 17 18 19 20 21 22 23 24 25* * .X X a a ? ?dotch

24、art(x) XJx?,? Cleveland dot ?(stacked plots line- by-line and column-by-column)pie(x) ?boxplot(x) ?sunflowerplot(x, y) ?.?q?I :?s?s?8?: ?coplot(xy | z) ?z ?m?x ?yVC?interaction.plot (f1, f2, y) XJf1?f2? ? f,?y ?, ?f1?x?f2 ?A?:?fun?y ? ?O?(?O?,fun=mean)matplot(x,y) ?,?x 1? ?Ay 1? , x 1?Ay 1 , ?ga?fou

25、rfoldplot(x) o? o? w?2 2 ?L?(x7 L?dim=c(2, 2,k) ?|, ?dim=c(2, 2) ? ?XJk =1)assocplot(x) CohenFriendly?,w?3 ? ?L?1, C?l?5 ?mosaicplot(x) ?L ?5?8? ?m?pairs(x) XJx ? ?x ? ?m ?plot.ts(x) XJx?ats ?,?x ?mS ?,x?, ?S 7Lk? ?mts.plot(x) ?, XJx? ?S ?k? ?m Lk? ?qqnorm(x) ?qqplot(x, y) ?x ?contour(x, y, z) ? ?p

26、? ?(x ? ? ? ? SO ? ? ? x?), x ?y 7 L ? ? ?,z 7 L ? ?,?dim(z)=c(length(x),length(y)(x?y ?)filled.contour(x, y, z) ?, p?m ? ,?A ? ?image(x, y, z) ?, ?S? ?L?persp(x, y, z) ?, ?stars(x) XJx ? ?,(/?x?,(?Lx z?1?L ?.symbols(x, y, .) 3dx ?y ?Ix?( ? ?/?/?(?O?/?), ? a.!? !? d, C?termplot(mod.obj) ?8 .(mod.obj

27、) (?)K?segments(x0, y0, x1, y1) l:(x0,y0) y?:(x1,y1)arrows(x0, y0, x1, y1, angle= 30, code=2) ?. code=2?:(x0,y0)? : ?, code=1?:(x1,y1)?: ?, code=3V?; angle ?m ? abline(a,b) ? ?a ?b? abline(h=y) 3y: R?abline(v=x)3x:Y? abline(lm.obj)?lm.obj?8? curve ?L?3?mfrom,to?rect(x1, y1, x2, y2) ?,m,.,p?x1, x2, y

28、1, and y2o/polygon(x, y) ?/?legend(x, y, legend) 3:(x,y)V?title() VIKaxis(side, at) V? I?,.?(side=1), ?(2), ?(3)? m?(4); ?at ?x? ?Ibox() 3 c?/?frug(x) 3x-?x?x ?locator(n, type=n, .) 3r?I3?:?ng?ng:? ?I(x, y)?3:?(type=p)?(type=l) ?e?x?(type=n)?par(.) 5?5UC?;?- ?.adj ?i?(0 ?, 0.5 ?, 1 m?)bg ? ?(X: bg=r

29、ed, bg=blue, . . . colors()? ?w?657?)bty ?/?/G,? ?:o, l, 7,c, u ? (?i?);XJbty=n K?cex ?G e?i?;e? ?k?U:cex.axis, ?I?, cex.lab, ?I?I, cex.main, IK,cex.sub,BIKcol ? ? ? ? ? ? ? ?;? ? ? ? ?: red, blue ? colors() ? ? ?#RRGGBB; ? rgb(), hsv(), gray(),?rainbow(); ?cex aq: col.axis, col.lab, col.main, col.s

30、ubps ?i?(points)pty ?a. i?s:?/, m: ?|tck ? ?z?/?!p? ?XJtck=1 K?gridtcl ?. ? 1 p?(%?tcl=-0.5)xaxt X Jxaxt=n K ?x-? ? w?(k? u?axis(side=1,.)?)yaxt ?. y-?(Lattice)?xyplot(yx)VC? barchart(yx) y ?x ? dotplot(yx) Cleveland :?(?1? ?) densityplot(x) ?histogram(x) x ?bwplot(yx) ?/?qqmath(x)x u,n? ?-?stripplo

31、t(yx) ?,x7L?., y?fqq(yx) ? ?, x7L?., y?,i?f, 7L?“Y?”splom(x) ?parallel(x) ?1?I?levelplot(zx*y|g1*g2) 3x?y ?I: z ? ? ?x?y?z ? wireframe(zx*y|g1*g2) 3d ?(?) cloud(zx*y|g1*g2) 3d?(:)3?5Lattice ?, yx|g1*g2 k?J?C?g1 ?g2 |?3? “panels”?. Lattice ? ?:N?,Xdata=,subset=. ?panel= 5?“panel”?(? apropos(panel)?ll

32、ines). Lattice ?trellis a. ?“print-ed”5)?/. S?print(xyplot(.)?,g? J. ?lattice.theme ?lset 5UCLattice %?.?optim(par, fn, method = c(Nelder-Mead, BFGS, CG, L-BFGS-B, SANN) u? ? ?.?uNelder-Mead, quasi-Newton and conjugate-gradient?. ?,?mS ?.par ?, fn ? ?(? )nlm(f,p)?L?(Newton-type)? ? z?lm(formula) ?5

33、.; formula ;./?response termA + termB + .; ? I(x*y) + I(x2) 5?5?glm(formula,family=) ?L?5?.? ?5?2?5 .; family? ? ? . ?;?familynls(formula) ?5? ? Oapprox(x,y=) ?5 ?;approxfun(x,y)?5 ?spline(x,y=) ?(?) ?splinefun(x,y) ?(?) ?loess(formula) ?Cq?8|? ?8?1?8?8?w?|? ?8N?k?:.?k? ?: data= ?C?, subset= ?v? f8;

34、 na.action= ?n?:na.fail, na.omit, ?. e?u .?: predict(fit,.) ?L? .fit O? ? df.residual(fit) ? gd?coef(fit) ?O X?k? ?)? IO ?residuals(fit) ? ?deviance(fit) ?fitted(fit) ?logLik(fit)O?q,?8AIC(fit) O? Akaike&EOK?Akaikeinformationcriterionor AIC?Oaov(formula) ? ?anova(fit,.) ? .? ? L? ?L?density(x) x ? O

35、kmeans(x) k ?ahclust(d, method = complete) g ? a ? ?, d d ? dist E,method? ?hclust prcomp(x, .) ? factanal(x,factors,data) ?f?cancor(x, y, xcenter = TRUE, ycenter = TRUE) O?k?( canonical correlations )ut.testtuwilcox.test Wilcoxon uprop.test(x,n,p) ng? ?,?y x V?V? p ?y b ubinom.test(x,n) ? uchisq.test(x,p) 2ufisher.test(x ,y = NULL) Fisher ?(5uks.test(x,y=name,) Kolmogorov-Smirnovu ,u ?l”name”?shapiro.test(x) Shapiro-Wilk ?u PP.test(x, lshort = TRUE) PP

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论