How to create a stair step plot of data in R/ggplot2?

Sunday, May 4, 2014

I have a list of points and I'd like to plot them and connect them with stair steps, like the following screenshot.

df <- read.table('out.dat')
df <- df[df$V1>0,]
st <- stats.bin(x=df$V1, y=df$V2, N=100)
df2 <-$stats["mean",])
names(df2) <- c('')
plot(df2$, type="s",
xlab="Off-axis distance (mm)", ylab="Mean Energy (MeV)")

How could I achieve the same with ggplot2 ?

enter image description here