%\ vignetteengine {knitr :: knitr}%\ vignetteIndexentry {02。使用R - 幻灯片} \ DocumentClass [XColor = DVIPSNAMES] {beamer} \ usepackage {bioConductorSlides} \ hypersetup {colorlinks,linkColor =,urlcolor = blue}\ Morgan \ footNote {\ url {mtmorgan@fhcrc.org}}}}} \ date {27-28 2014年2月27日至28日} \ begin {document} \ maketitle \ e节\ begin {columns} \ column {.45 \ textWidth} \ begin {initizize} \ item \ url {http://r-project.org} \ item open-source,统计编程语言;广泛用于学术界,金融,制药,\ ldots \ item Core语言和基本软件包\ Item Interactive Sessions,脚本\ item $> 5000 $贡献包\ end {itemize} \ column {.55 \ textWidth} < > = ##两个'vectors'x <-rnorm(1000)y < - x + rnorm(1000,sd = .5)##集成容器df < - data.frame(x = x,y = y)##可视化图(y〜x,df)##回归;'对象'fit <-lm(y〜x,df)##对象abline(fit)上的方法#回归行anv aNV <-Anova(fit)#anova table @ enova table @ end {columns} \ end {frame} \ begin{frame} {编程\ r} \ begin {emumerate} \ item packages:加载,安装\ item help help \ item scripts \&reproducible Research \ itek \ item functions \ item bugging \ item decugging和semal performance \ end eND {enumerate {enumerate}开始{frame} [脆弱] {1。软件包}已经安装了软件包< > =库(Parallel) @ %%新软件包来自\ emph {repositories},例如\ href {http://cran.r-project.org} {cran} {cran}和\ href {//www.andersvercelli.comg/}{BioConductor} \ begin {initizize} \ item \ rcode {bioClite()}要安装,包括\ emph {dependencies} \ item偶尔偶尔问题,当软件包取决于第三方软件安装\ end End \ end end en eend \ end Endize} > = source(“ //www.andersvercelli.com/bioclite.r”)bioclite(“ iranges”)library(“ iranges”) @ %%其他存储库:\ texttt {r-forge}\ ldots \ end {frame} \ begin {frame} [fragile] {packages(cont。)}加载了哪些软件包?< > = head(search(),3) @软件包提供了哪些功能?< > = help(package =“ iranges”) @ \ r {}如何找到符号,例如。\ rcode {sin}?\begin{itemize} \item Look in \Rcode{.GlobalEnv}, then proceed down search path \item Specify package with \Rcode{base::sin} \end{itemize} \end{frame} \begin{frame}[脆弱] {2。help} \ begin {knitRout} \ decteColor {shadeColor} {rgb} {0.969,0.969,0.969,0.969} \ color {fgcolor} \ begin {kframe}\ hlkwd {?} \ hlstd {data.frame} \ hlkwd {?} \ hlstd {anova} \ hlkwd {?} \ hlstd {anova.lm} \ hlcom {#anova generic,类LM} \ hlKWD {类?} \ hlstd {dnastringset} \ hlkwd {方法?} \ hlstr {“ alphabetfrequency,dnastringset”} \ hlkwd {vignette} \ hlstd {(} \ hlstd {(} \ hlstr {“ genomicrangesintroduction”}hlstd {(} \ hlkwc {pack} \ hlstd {=} \ hlstr {“ bioStrings”} \ hlstd {)} \ hlstd {)\ hlkwd {rshowdoc} \end{alltt} \end{kframe} \end{knitrout} \end{frame} \begin{frame}{3. Scripts, functions, and reproducible research} \begin{enumerate} \item Write simple scripts of \R{} code \texttt{my\_analysis.R} \item Implement common operations as functions. \item `Markdown' with \R{} code embedded in surrounding text \texttt{my\_analysis.Rmd} \item Packages! -- \Rcode{package.skeleton()} \item Version control! \end{enumerate} \end{frame} \begin{frame}{4. Favorite functions} \begin{columns}[t] \column{.5\textwidth} \begin{description}\itemsep0pt\parskip0pt \item[\Rfunction{dir}, \Rfunction{read.table}, \Rfunction{scan}] List files; input data. \item[\Rfunction{c}, \Rfunction{factor}, \Rfunction{data.frame}, \Rfunction{matrix}] Create vectors, etc. \item[\Rfunction{summary}, \Rfunction{table}, \Rfunction{xtabs}] Summarize or cross-tabulate data. \item[\Rfunction{t.test}, \Rfunction{lm}, \Rfunction{anova}] Compare two or several groups. \item[\Rfunction{dist}, \Rfunction{hclust}, \Rfunction{heatmap}] Cluster data. \item[\Rfunction{plot}] Plot data. \item[\Rfunction{ls}, \Rfunction{library}] List objects; attach packages. \end{description} \column{.5\textwidth} \begin{description} \itemsep0pt\parskip0pt \item[\Rfunction{lapply}, \Rfunction{sapply}, \Rfunction{mapply}] Apply function to elements of lists. \item[\Rfunction{match}, \Rfunction{\%in\%}] find elements of one vector in another. \item[\Rfunction{split}, \Rfunction{cut}] Split or cut vectors. \item[\Rfunction{strsplit}, \Rfunction{grep}, \Rfunction{sub}] Operate on character vectors. \item[\Rfunction{biocLite}] Install a package from an on-line repository. \end{description} \end{columns} \end{frame} \begin{frame}{5. Debugging and measuring performance} Debugging \begin{itemize} \item \Rfunction{traceback()}: what went wrong? \item \Rfunction{debug()}: step through a function. \item \Rfunction{browser()}: insert a break-point in your own function / script. Help debug errors. \end{itemize} \end{frame} \begin{frame}{Debugging and measuring performance (cont.)} Performance \begin{itemize} \item \Rfunction{all.equal()}, \Rfunction{identical()} to compare values. \item \Rfunction{system.time()} to measure how long evaluation takes. \item \Rpkg{microbenchmark} to compare times for different functions \item \Rfunction{Rprof()} to summarize time in each function call, \href{https://github.com/hadley/lineprof}{lineprof} to profile each line of code \end{itemize} \end{frame} \end{document}