ebook img

R Markdown: The Definitive Guide PDF

339 Pages·2018·4.64 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview R Markdown: The Definitive Guide

R Markdown The Definitive Guide Chapman & Hall/CRC The R Series Series Editors John M. Chambers, Department of Statistics Stanford University Stanford, California, USA Torsten Hothorn, Division of Biostatistics University of Zurich Switzerland Duncan Temple Lang, Department of Statistics University of California, Davis, California, USA Hadley Wickham, RStudio, Boston, Massachusetts, USA Recently Published Titles bookdown: Authoring Books and Technical Documents with R Markdown Yihui Xie Testing R Code Richard Cotton R Primer, Second Edition Claus Thorn Ekstrøm Flexible Regression and Smoothing: Using GAMLSS in R Mikis D. Stasinopoulos, Robert A. Rigby, Gillian Z. Heller, Vlasios Voudouris, Fernanda De Bastiani The Essentials of Data Science: Knowledge Discovery Using R Graham J. Williams blogdown: Creating Websites with R Markdown Yihui Xie, Alison Presmanes Hill, Amber Thomas Handbook of Educational Measurement and Psychometrics Using R Christopher D. Desjardins, Okan Bulut Displaying Time Series, Spatial, and Space-Time Data with R, Second Edition Oscar Perpinan Lamigueiro Reproducible Finance with R Jonathan K. Regenstein, Jr R Markdown: The Definitive Guide Yihui Xie, J.J. Allaire, Garrett Grolemund For more information about this series, please visit: https://www.crcpress.com/go/the-r-series R Markdown The Definitive Guide Yihui Xie J. J. Allaire Garrett Grolemund CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2019 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Printed on acid-free paper Version Date: 20180702 International Standard Book Number-13: 978-1-138-35933-8 (Paperback) International Standard Book Number-13: 978-1-138-35942-0 (Hardback) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com To Jung Jae-sung (1982 – 2018), aremarkablyhard-workingbadmintonplayerwitharemarkably simpleplayingstyle Contents ListofTables xvii ListofFigures xix Preface xxiii AbouttheAuthors xxxiii I GetStarted 1 1 Installation 3 2 Basics 5 2.1 Exampleapplications . . . . . . . . . . . . . . . . . . . . . 9 2.1.1 Airbnb’sknowledgerepository . . . . . . . . . . . . 9 2.1.2 HomeworkassignmentsonRPubs . . . . . . . . . . 10 2.1.3 Personalizedmail . . . . . . . . . . . . . . . . . . . 10 2.1.4 2017EmployerHealthBenefitsSurvey. . . . . . . . 11 2.1.5 Journalarticles . . . . . . . . . . . . . . . . . . . . . 12 2.1.6 Dashboardsateelloo . . . . . . . . . . . . . . . . . 12 2.1.7 Books. . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.1.8 Websites . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2 CompileanRMarkdowndocument . . . . . . . . . . . . . 14 2.3 Cheatsheets . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.4 Outputformats . . . . . . . . . . . . . . . . . . . . . . . . 16 2.5 Markdownsyntax . . . . . . . . . . . . . . . . . . . . . . . 19 2.5.1 Inlineformatting . . . . . . . . . . . . . . . . . . . 19 2.5.2 Block-levelelements . . . . . . . . . . . . . . . . . 20 2.5.3 Mathexpressions . . . . . . . . . . . . . . . . . . . 23 2.6 RcodechunksandinlineRcode . . . . . . . . . . . . . . . 24 2.6.1 Figures . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.6.2 Tables . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.7 Otherlanguageengines . . . . . . . . . . . . . . . . . . . . 30 vii viii Contents 2.7.1 Python . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.7.2 Shellscripts . . . . . . . . . . . . . . . . . . . . . . 34 2.7.3 SQL . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.7.4 Rcpp . . . . . . . . . . . . . . . . . . . . . . . . . . 37 2.7.5 Stan . . . . . . . . . . . . . . . . . . . . . . . . . . 39 2.7.6 JavaScriptandCSS . . . . . . . . . . . . . . . . . . 39 2.7.7 Julia . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.7.8 CandFortran . . . . . . . . . . . . . . . . . . . . . 40 2.8 Interactivedocuments . . . . . . . . . . . . . . . . . . . . . 41 2.8.1 HTMLwidgets . . . . . . . . . . . . . . . . . . . . 41 2.8.2 Shinydocuments . . . . . . . . . . . . . . . . . . . 42 II OutputFormats 47 3 Documents 49 3.1 HTMLdocument . . . . . . . . . . . . . . . . . . . . . . . 49 3.1.1 Tableofcontents . . . . . . . . . . . . . . . . . . . . 50 3.1.2 Sectionnumbering . . . . . . . . . . . . . . . . . . 51 3.1.3 Tabbedsections . . . . . . . . . . . . . . . . . . . . 51 3.1.4 Appearanceandstyle . . . . . . . . . . . . . . . . . 52 3.1.5 Figureoptions . . . . . . . . . . . . . . . . . . . . . 54 3.1.6 Dataframeprinting . . . . . . . . . . . . . . . . . . 55 3.1.7 Codefolding . . . . . . . . . . . . . . . . . . . . . . 56 3.1.8 MathJaxequations. . . . . . . . . . . . . . . . . . . 57 3.1.9 Documentdependencies . . . . . . . . . . . . . . . 58 3.1.10 Advancedcustomization . . . . . . . . . . . . . . . 59 3.1.11 Sharedoptions . . . . . . . . . . . . . . . . . . . . . 62 3.1.12 HTMLfragments . . . . . . . . . . . . . . . . . . . 62 3.2 Notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.2.1 UsingNotebooks . . . . . . . . . . . . . . . . . . . 63 3.2.2 Savingandsharing . . . . . . . . . . . . . . . . . . 72 3.2.3 Notebookformat . . . . . . . . . . . . . . . . . . . 73 3.3 PDFdocument . . . . . . . . . . . . . . . . . . . . . . . . . 78 3.3.1 Tableofcontents . . . . . . . . . . . . . . . . . . . . 79 3.3.2 Figureoptions . . . . . . . . . . . . . . . . . . . . . 80 3.3.3 Dataframeprinting . . . . . . . . . . . . . . . . . . 80 3.3.4 Syntaxhighlighting . . . . . . . . . . . . . . . . . . 81 3.3.5 LaTeXoptions . . . . . . . . . . . . . . . . . . . . . 81 3.3.6 LaTeXpackagesforcitations . . . . . . . . . . . . . 82 3.3.7 Advancedcustomization . . . . . . . . . . . . . . . 83 Contents ix 3.3.8 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 84 3.4 Worddocument . . . . . . . . . . . . . . . . . . . . . . . . 85 3.4.1 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 85 3.5 OpenDocumentTextdocument . . . . . . . . . . . . . . . . 86 3.5.1 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 86 3.6 RichTextFormatdocument . . . . . . . . . . . . . . . . . . 87 3.6.1 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 87 3.7 Markdowndocument . . . . . . . . . . . . . . . . . . . . . 88 3.7.1 Markdownvariants . . . . . . . . . . . . . . . . . . 88 3.7.2 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 89 3.8 Rpackagevignette . . . . . . . . . . . . . . . . . . . . . . 90 4 Presentations 93 4.1 ioslidespresentation . . . . . . . . . . . . . . . . . . . . . . 93 4.1.1 Displaymodes . . . . . . . . . . . . . . . . . . . . . 95 4.1.2 Incrementalbullets . . . . . . . . . . . . . . . . . . 95 4.1.3 Visualappearance . . . . . . . . . . . . . . . . . . . 96 4.1.4 Codehighlighting . . . . . . . . . . . . . . . . . . . 98 4.1.5 Addingalogo . . . . . . . . . . . . . . . . . . . . . 98 4.1.6 Tables . . . . . . . . . . . . . . . . . . . . . . . . . 99 4.1.7 Advancedlayout . . . . . . . . . . . . . . . . . . . 100 4.1.8 Textcolor . . . . . . . . . . . . . . . . . . . . . . . 100 4.1.9 Presentermode . . . . . . . . . . . . . . . . . . . . 101 4.1.10 PrintingandPDFoutput . . . . . . . . . . . . . . . 101 4.1.11 Customtemplates . . . . . . . . . . . . . . . . . . . 101 4.1.12 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 102 4.2 Slidypresentation . . . . . . . . . . . . . . . . . . . . . . . 102 4.2.1 Displaymodes . . . . . . . . . . . . . . . . . . . . . 104 4.2.2 Textsize . . . . . . . . . . . . . . . . . . . . . . . . 104 4.2.3 Footerelements . . . . . . . . . . . . . . . . . . . . 105 4.2.4 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 105 4.3 Beamerpresentation . . . . . . . . . . . . . . . . . . . . . . 106 4.3.1 Themes . . . . . . . . . . . . . . . . . . . . . . . . . 107 4.3.2 Slidelevel . . . . . . . . . . . . . . . . . . . . . . . 108 4.3.3 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 109 4.4 PowerPointpresentation . . . . . . . . . . . . . . . . . . . 109 4.4.1 Customtemplates . . . . . . . . . . . . . . . . . . . 112 4.4.2 Otherfeatures . . . . . . . . . . . . . . . . . . . . . 113 III Extensions 115

Description:
R Markdown: The Definitive Guideis the first official book authored by the core R Markdown developers that provides a comprehensive and accurate reference to the R Markdown ecosystem. With R Markdown, you can easily create reproducible data analysis reports, presentations, dashboards, interactive ap
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.