User:Timothee Flutre/Notebook/Postdoc/2011/11/07: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
(→‎About R: add useful links on R's bad sides)
(→‎About R: update R pkg book)
(8 intermediate revisions by the same user not shown)
Line 12: Line 12:
* '''Documentation''':
* '''Documentation''':
** try it [https://www.codeschool.com/courses/try-r online]
** try it [https://www.codeschool.com/courses/try-r online]
** learn how to use it with [http://swirlstats.com/ swirl]
** official introductory [http://cran.r-project.org/doc/manuals/R-intro.html manual]
** official introductory [http://cran.r-project.org/doc/manuals/R-intro.html manual]
** well-organized [http://www.statmethods.net/ how-to]
** well-organized [http://www.statmethods.net/ how-to]
** condensed [http://cran.r-project.org/doc/contrib/Baggott-refcard-v2.pdf reference card]
** freely-available [http://adv-r.had.co.nz/ book] for advanced usage
** freely-available [http://adv-r.had.co.nz/ book] for advanced usage
** [http://www.r-bloggers.com/ aggregator] of R blogs
** [http://www.r-bloggers.com/ aggregator] of R blogs
** compatible with [http://ess.r-project.org/ ESS] (emacs mode), besides other IDEs such as [http://www.rstudio.com/ Rstudio]
** [http://rpubs.com/ publishing platform] of R documents
** [http://gallery.rcpp.org/ gallery] of examples extending R with C++ via [http://www.rcpp.org/ Rcpp]
** compatible with [http://ess.r-project.org/ ESS] ([https://openwetware.org/wiki/User:Timothee_Flutre/Notebook/Postdoc/2012/07/25 Emacs] mode), besides other IDEs such as [http://www.rstudio.com/ Rstudio]
** but R language specifications are unconventional ([https://github.com/tdsmith/aRrgh aRgh], John Cook's [http://www.johndcook.com/R_language_for_programmers.html doc], [http://www.burns-stat.com/pages/Tutor/R_inferno.pdf R Inferno])
** but R language specifications are unconventional ([https://github.com/tdsmith/aRrgh aRgh], John Cook's [http://www.johndcook.com/R_language_for_programmers.html doc], [http://www.burns-stat.com/pages/Tutor/R_inferno.pdf R Inferno])


* '''Tips''':
* '''Tips''':
** explicit [https://github.com/jtleek/rpackages policy] for packages development by Jeff Leek in his lab
** [http://menugget.blogspot.de/2013/01/my-template-for-controlling-publication.html procedure] for publication-quality plots
** [http://menugget.blogspot.de/2013/01/my-template-for-controlling-publication.html procedure] for publication-quality plots
** [https://sites.google.com/site/rosselldavid/home/tips tutorial] to debug within Emacs some C/C++ code called by R
** make your own R package: [https://github.com/jtleek/rpackages policy] from Jeff Leek, [http://r-pkgs.had.co.nz/ book] from Hadley Wickham, [http://projecttemplate.net/ ProjectTemplate]
** R [http://google-styleguide.googlecode.com/svn/trunk/Rguide.xml style guide] from Google
** [http://cran.r-project.org/bin/linux/ubuntu/ upgrade] R on Ubuntu


* customize the built-in heatmap in R (inspired from [http://stackoverflow.com/questions/5687891/r-how-do-i-display-clustered-matrix-heatmap-similar-color-patterns-are-grouped/5694349 this]):
S <- 3  # nb of subgroups
V <- 7  # nb of observations
z <- matrix(c(0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0), nrow=V, ncol=S, byrow=TRUE)
myheatmap <- function(z, out.file="") {
  def.par <- par(no.readonly=TRUE)
  par(mar=c(4,5,3,2), font=2, font.axis=2, font.lab=2, cex=1.5, lwd=2)
  if (out.file != "")
    pdf(out.file)
  layout(mat=cbind(1, 2), width=c(7,1))  # plot +  legend
  mycol <- rev(heat.colors(4))
  image(x=1:NCOL(z), y=1:NROW(z), z=t(z),
        xlim=0.5+c(0,NCOL(z)), ylim=0.5+c(0,NROW(z)),
        xlab="", ylab="Observations sorted by cluster", main="Custom heatmap",
        axes=FALSE, col=mycol)
  axis(1, 1:NCOL(z), labels=paste("subgroup", 1:NCOL(z)), tick=0)
  par(mar=c(0,0,0,0))
  plot.new()
  legend("center", legend=sprintf("%.2f", seq(from=min(z), to=max(z), length.out=5)[-1]),
          fill=mycol, border=mycol, bty="n")
  if (out.file != "")
    dev.off()
  par(def.par)
  }
myheatmap(mydata.sort)


<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### -->
<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### -->

Revision as of 15:01, 1 July 2015

Project name <html><img src="/images/9/94/Report.png" border="0" /></html> Main project page
<html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>Previous entry<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>Next entry<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html>

About R

  • Motivation: when analyzing data for any research project, it's essential to be able to quickly clean the raw data, transform them, plot intermediary results, calculate summary statistics, try various more-or-less sophisticated models, etc. This must be easily doable with small as well as large data sets, interactively or not. Several tools exist to fill exactly this need, and R is only one of them, but I especially recommend it because it is build by statisticians (this means that the implemented models are numerous and state-of-the-art). Moreover, it's open-source (and even free software), platform-independent, full of packages, with well-documented resources, etc, so give it a try!