There are plenty of books on portfolio issues built according to formula "some theory + some R code (or Matlab, or S - which is very similar to R)". See for example
- Pfaff B. Financial Risk Modelling and Portfolio Optimization with R.// 2013.
- Best M.J. Portfolio Optimization. Chapman & Hall, 2010.
- Würtz D. et al. Portfolio Optimization with R/Rmetrics. // Rmetrics, 2009.
- Sherer B, Martin R.D. Introduction to Modern Portfolio Optimization With NUOPT and S-PLUS. // 2006.
 is with examples from many R packages, and covers not only MPT but risk issues and MPT+ things like Black-Litterman and Meucci's approaches.  is based on Matlab examples, have very comprehensive optimization basics, and is more like quant-student-oriented book (unlike  which is more quant-PhD-advanced-portfolio-managers-oriented).  is entirely dedicated to Rmetrics R packages for optimizatioin, with some very basic theory. More like introductory thing, suitable for everyone from for bachelor student to somebody looking for a good coding-oriented start in the field.  is the oldest book, based on S, but all examples are easily translatable to R. Hence, no packages are introduced + the reader is supposed to be able to cope with some difficulties when translating from S to R. But still there are a few interesting advanced things in the book.