Stata linetype palette (discrete)

library(reshape2) # for melt
library(plyr) # for ddply
library(ggplot2)
ecm <- melt(economics, id = "date")
rescale01 <- function(x) {(x - min(x)) / diff(range(x))}
ecm <- ddply(ecm, "variable", transform, value = rescale01(value))
## Error in eval(expr, envir, enclos): could not find function "rescale01"
qplot(date, value, data=ecm, geom="line", linetype=variable) + scale_linetype_stata()

plot of chunk scale_linetype_stata