# Monthly Archives: August 2009

## Example 7.11: Plot an empirical cumulative distribution function from scratch

August 31, 2009
By

In example 7.8, we used built-in functions to produce an empirical CDF plot. But the empirical cumulative distribution function (CDF) is simple to calculate directly, and it might be useful to have more control over its appearance than is aﬀorded by...

## Formatting Decimals in Texts with R

August 30, 2009
By

anping Chen raised a question in the Chinese COS forum on the output of Eviews: how to (re)format the decimal coefficients in equations as text output? For example, we want to round the numbers in CC = 16.5547557654 + 0.0173022117998*PP + 0.216234040485 * PP(-1) + 0.810182697599 * (WP + WG) to the 3rd decimal places.

## Counterintuitive Results in Flipping Coins

August 28, 2009
By

oin-flipping is a rather old topic in probability theory, so most of us think we know very well about it, however, the other day I saw a question about this old topic (in David Smith’s REvolution?) which was beyond me expectation: how many times do we need to flip the coin until we get a

## ‘R’ programming

August 28, 2009
By

http://en.wikibooks.org/wiki/R_Programming

## Learning R 2009-08-28 13:11:00

August 28, 2009
By

fydeficit.1projectedpng("c:/data/deficit_color.png",height=480,width=480)plot(deficit.1~fy,ylim=c(-12,5),type="n",lwd=2,col="red",main="Federal budget deficit, 1990-2019",cex.lab=1.1,cex.axis=.75,xlab="Fiscal year",ylab="Deficit (% of GDP)")rect(1988,-15,1994,6,col="#FF9999",border=NA)rect(1994,-15,2002,6,col="#6699FF",border=NA)rect(2002,-15,2010,6,col="#FF9999",border=NA)rect(2010,-15,2014,6,col="#6699FF",border=NA)rect(2014,-15,2021,6,col="#CCCCCC",border=NA)abline(h=0,lwd=.5,lty=3,col="#555555")lines(fy,deficit.1,lwd=2.5)lines(fy,projected,lwd=2.5,lty=2)rect(1990,-11.5,2000,-9.5,col="#dddddd",border="#555555")text(1995,-10.5,"Source: CBO")graphics.off()

## Learning R 2009-08-28 13:11:00

August 28, 2009
By

fydeficit.1projectedpng("c:/data/deficit_color.png",height=480,width=480)plot(deficit.1~fy,ylim=c(-12,5),type="n",lwd=2,col="red",main="Federal budget deficit, 1990-2019",cex.lab=1.1,cex.axis=.75,xlab="Fiscal year",ylab="Deficit (% of GDP)")rect(1988,-15,1994,6,col="#FF9999",border=NA)rect(1994,-15,2002,6,col="#6699FF",border=NA)rect(2002,-15,2010,6,col="#FF9999",border=NA)rect(2010,-15,2014,6,col="#6699FF",border=NA)rect(2014,-15,2021,6,col="#CCCCCC",border=NA)abline(h=0,lwd=.5,lty=3,col="#555555")lines(fy,deficit.1,lwd=2.5)lines(fy,projected,lwd=2.5,lty=2)rect(1990,-11.5,2000,-9.5,col="#dddddd",border="#555555")text(1995,-10.5,"Source: CBO")graphics.off()

## Combine R CMD build and junit

August 28, 2009
By

This is a post in the series Mixing R CMD build and ant. Previous posts have shown how to compile the java code that lives in the src directory of a package and how to document this code using javadoc. This post tackles the problem of unit testin...

## A Fast Intro to PLYR for R

August 27, 2009
By

I’m not dead yet! Although it has been rumored that I am. The new job is going great and I’m thrilled to be with a new firm doing interesting work alongside smart people. It makes me seem smarter by simple association. There’s been a lot going on recently in the R user community. There was an

## Using R and Bioconductor for sequence analysis

August 26, 2009
By

Here's another quick R vignette, in case I pick this up later and need to remind myself where I got stuck. I was trying to use R for a bit of basic sequence analysis, with mixed results.First, install the BSgenome package, which is part of Bioconductor...

## ggplot2 Version of Figures in “Lattice: Multivariate Data Visualization with R” (Final Part)

August 25, 2009
By

Over the past weeks I have tried to replicate the figures in Lattice: Multivariate Data Visualization with R using Hadley Wickham’s ggplot2. With the exception of a few graph types (e.g. ggplot2 doesn’t support 3d-graphs, and there were a few other cases), it was possible to create ggplot2 versions of almost all the figures. Sometimes this