The Kolmogorov-Smirnov statistic is defined as the maximum distance between the empirical and the hypothesized cumulative distribution function. Rather than looking at numbers, I think it is much preferable to locate the maximum difference using a graph.
I know how to plot the empirical distribution function
p1<-qplot(rnorm(30),stat="ecdf",geom="step")
but could you please tell me how I could add on the same plot the cumulative distribution function of the theoretical distribution? For my case, the theoretical distribution is the standard normal but I am interested in the generalization to every distribution function.
Thank you.

pnorm:x <- seq(-3, 3, length = 100); plot(x, pnorm(x)). For other distributions, use e.g.pbeta,pcauchy, etc. - Gregor Thomas