Posts – Page 2

Mathematical expressions in plots

Download as R Markdown.

Mathematical expressions can be included in the plot title or axis labels. For more information, see ?plotmath or run the demo with demo(plotmath).

Here are some quick examples.

Example 1

plot(0, 0, main = expression(theta == 0), ylab = expression(hat(gamma) == 0), 
    xlab = expression(sum ...

Plotting with Lattice

Download as R Markdown.

The lattice library is useful for quickly making plots of multivariate data. It's easy to make plots which condition on one or more variables.

Load the lattice library

library(lattice)

# Ask for general information about the lattice package
`?`(package, lattice)

# See what is inside of ...

mapply

Download as R Markdown.

mapply gives us a way to call a non-vectorized function in a vectorized way.

From the R Documentation:

mapply is a multivariate version of sapply. mapply applies FUN to
the first elements of each ... argument, the second elements,
the third elements, and so on. Arguments are ...

R Base Graphics Plotting

Download as R Markdown.

Important parameters

  • pch: plotting symbol
  • lty: line type
  • lwd: line width
  • col: plotting color
  • las: orientation of axis labels
  • bg: background color
  • mar: margin size
  • oma: outer margin size
  • mfrow: number of plots per row, column. Plots filled in row-wise.
  • mfcol: number of plots per row ...

tapply and split

Download as R Markdown.

tapply

Apply a function over subsets of a vector.

Example: Take group means with tapply.

x <- c(rnorm(10), runif(10), rnorm(10, 1))
x
##  [1] -2.04333  0.72651  1.55476 -0.12411  1.08133 -0.30514  1.38638
##  [8]  0.35047  0.88147  1 ...

Parsing in Python

How to parse in python

Wrapping Python Dictionaries

How to wrap a python dictionary for IPython autocompletion.

Start Me Up!

My first post.