Bits & Bites

This is my portal page of bits and pieces.

Packages & functions

  • base::unique(). More than one variables.
  • Remove NA. 1) any NA-related parameters, particularly in built-in function? 2) if not,  do something like d <- d[!]. Note: d != NA does NOT work! Read more.
  • Group data.frame into subgroups by column: split(). It may be really slow if the column is factor.
  • write lines to a text file, e.g. write Log file
  • File manipulation: file.exists(), file.create(), file.remove(), file.append(), file.append(), file.copy(), file.symlink(),
  • Save and load R objects
  • getopt package for parsing command parameters
  • XML package: reading, parsing, creating XML files
  • stringr package: make easier to work with strings, such as but not limited to proper dealing with NAs and zeros.
  • tm package: text mining framework
  • reshape2 package: restructure and aggregate data using just two functions: melt and cast.
  • Markdown: a format that enables easy authoring of reproducible web reports from R. In practice, knitr package first weaves R markdown (.rmd) files into plain markdown (.md) files, and then markdown package converts markdown files into HTML documents.
  • Sweave: weave Rnw files into TeX files that are then compiled into PDFs. The purpose is to create dynamic reports, which can be updated automatically if data or analysis change. In practice, you may use knitr (homepage), an R package that adds many new capabilities to Sweave.
  • Slidify: write slides in Rmd format. Example.
  • rCharts (R to JavaScript): a very powerful package to create, customize and publish interactive javascript visualizations from R using a familiar lattice style plotting interface. Tips: 1) generate time series chart by Richshaw, 2) Method html() gives the html code.
  • d3Network: create d3 JS directed network graphs.
  • RCurl: curl interface of R
  • print() – leading numbers, cat() – no leading numbers
  • Redirect console output to variable: capture.output() and sink()
  • file.path() constructs the path to a file from components in a platform-independent way.
  • foreach for parallel computation.
  • Circos like plot
  • OpenCPU

Digest articles

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s