This book shows how statistical methods can be applied in R and RStudio. It covers data management, simple statistical procedures, modeling and regression, and graphics. Each section begins with a brief introduction to the procedures and then presents the code. The book provides detailed worked examples together with output from the software to illustrate how the methods are applied in practice. It also includes an index of commands as well as topics.

The first edition of this popular guide provided a reference for R using an easy-to-understand, dictionary-like approach. Retaining the same accessible format, this second edition explains how to easily perform an analytical task in R without having to navigate through the extensive, idiosyncratic, and sometimes unwieldy software documentation. The book covers many common tasks, such as data management, descriptive summaries, inferential procedures, regression analysis, and graphics, along with more complex applications.

### New to the Second Edition

This edition now covers RStudio, a powerful and easy-to-use interface for R. It incorporates a number of additional topics, including using application program interfaces (APIs), accessing data through database management systems, using reproducible analysis tools, and statistical analysis with Markov chain Monte Carlo (MCMC) methods and finite mixture models. It also includes extended examples of simulations and many new examples.

This is the second edition of a popular book on using R for statistical analysis and graphics. We have focused on adding many new examples to this new edition. These examples are presented primarily in new chapters based on the following themes: simulation, probability, statistics, mathematics/computing, and graphics. We have also added many other updates, including a discussion of RStudio—a very popular development environment for R, and illustrations of new functionality from the dplyr, tidyr, and related packages. New topics include making and annotating maps, scraping" data from the web, mining text files, and generating dynamic graphics using ggvis and Shiny.### Reviews of the Second Edition

Overall, the book is easy to use. I have had it on my desk for the past few weeks and it has become invaluable. For those, like me, who find themselves regularly switching between R, Matlab, and Python - or similar packages - it can save a lot of time. (Jordi Prats,*Significance*, February 2016)

### Reviews of the First Edition

"This book is an excellent reference resource. Used this way, it can be helpful for years to come for both experienced and novice users. The organization of the material makes it easy to find the relevant piece of information either by topic (from the table of contents) or using one of the indexes. The task entries are self-contained. Users with experience in technical computing may use it as a quick starter in R, as well."
(Georgi N. Boshnakov, *Journal of Applied Statistics*, June 2012)

"This book provides a concise reference and annotated examples for R … . It is needed because R does not come with a coordinated manual … It is much easier to find information in Horton and Kleinman’s book because of their more detailed indices and table of contents. … Horton and Kleinman have succeeded very well in their goal of providing a concise reference manual and annotated examples. If you know the statistics (or can look them up) and have some experience using R, it is an extremely useful reference, and it has become my most consulted R book. … it would be an excellent reference for those wanting look up the syntax of a command together with an example of how to use it. It is also very useful if you cannot remember the command and want to know how to do it in R."
(Paul H. Geissler, *The American Statistician*, November 2011)

"The interesting aspect of the book is that it does not only describe the basic statistics and graphics function of the basic R system but it describes the use of 40 additional available from the CRAN website. The website contains also the R code to install all the packages that contain the described features. In summary, the book is a useful complement to introductory statistics books and lectures … Those who know R might get additional hints on new features of statistical analyses."
(*International Statistical Review*, 2011)