Margot Tollefson
R 4 Quick Syntax Reference
A Pocket Guide to the Language, APIs and Library
3rd ed.Logo of the publisher
Margot TollefsonVanward Statistics, PO Box 286, 612 Teneyck Avenue, Stratford, IA, 50249-0286, USA
ISBN 978-1-4842-7923-6 e-ISBN 978-1-4842-7924-3
https://doi.org/10.1007/978-1-4842-7924-3
Margot Tollefson 2022
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress Media, LLC part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
This edition is dedicated to my parents, Roy and Alice Marie, who stood by me.
Introduction
In this third edition of R Quick Syntax Reference, there is more of an emphasis on RStudio and the conveniences that RStudio provides. The book continues to cover how to download and update R and RStudio, how to work with both programs, the types (and modes) and classes of R objects and expressions, using the S4 object system (at the introductory level), working with and creating scripts and functions, and importing from and exporting to external files. Also, working with objects that have dimensions, working with character objects, controlling the flow of a function or group of expressions, running some useful functions (in more and less detail), and working with some trickier parts of R.
This edition focuses on object and expression types rather than modes. The coverage of the S4 object system remains the same as in the second edition, but the Reference Class object system now has a couple of sections. In Chapter , has been expanded to cover most of the importing and exporting functions that are in the default packages loaded by R.
In Chapter , the last example has been substantially changed (but still codes the same process). The other examples in the chapter remain the same, although some argument names have been changed.
A few more functions are presented in Chapters , the functions are organized by subject matter more than in the first two editions.
Chapter .
My purpose in writing and revising this book has been to provide a useful reference for using the versatile R language. I feel the book achieves the purpose of the book. I hope the reader does too.
Source Code
All source code associated with this book can be accessed at http://github.com/apress/r4-quick-syntax-reference .
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub (https://github.com/Apress). For more detailed information, please visit http://www.apress.com/source-code.
Acknowledgments
First, I would like to acknowledge the R Core Team at the R Foundation for Statistical Computing, Vienna, Austria. The team provides for the help pages in R, without which this book would not have been possible. The technical editor, Matt Wiley, gave many good suggestions and corrections, for which I would like to thank him. I would also like to acknowledge the editors, Mark Powers, Nirmal Selvaraj, and Steve Anglin, at Apress for their help. And, per usual, I would like to thank my husband, Clay Conard, for his patience as I spent days writing and for his support.
Table of Contents
Part I: R Basics
Part II: Kinds of Objects
Part III: Functions
Part IV: I/O and Manipulating Objects
Part V: Flow Control
Part VI: Some Common Functions, Packages, and Techniques
About the Author
Margot Tollefsonis a self-employed consulting statistician residing in the tiny town of Stratford in the corn and bean fields of central Iowa. Her business is Vanward Statistics. She started using the S-Plus language in the early 1990s and was happy to switch to R over 18 years ago. Margot enjoys writing her own functions in Rto do plots and simulations as well as to implement custom modeling and to use published statistical methods. She earned her graduate degrees in statistics from Iowa State University in Ames, Iowa.
About the Technical Reviewer
Matt Wileyleads institutional effectiveness, research, and assessment at Victoria College, facilitating strategic and unit planning, data-informed decision making, and state/regional/federal accountability. As a tenured, associate professor of mathematics, he won awards in both mathematics education (California) and student engagement (Texas). Matt earned degrees in computer science, business, and pure mathematics from the University of California and Texas A&M systems.
Outside academia, he coauthors books about the popular R programming language and was managing partner of a statistical consultancy for almost a decade. He has programming experience with R, SQL, C++, Ruby, Fortran, and JavaScript.
A programmer, a published author, a mathematician, and a transformational leader, Matt has always melded his passion for writing with his joy of logical problem solving and data science. From the boardroom to the classroom, he enjoys finding dynamic ways to partner with interdisciplinary and diverse teams to make complex ideas and projects understandable and solvable.
The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
M. Tollefson R 4 Quick Syntax Reference https://doi.org/10.1007/978-1-4842-7924-3_11. Downloading R and RStudio and Setting Up a File System
Margot Tollefson
(1)Vanward Statistics, PO Box 286, 612 Teneyck Avenue, Stratford, IA, 50249-0286, USA
R is an open source statistical programming language based on the commercial programming language S. The S language was developed at Bell Laboratories in the 1970s and 1980s, mainly by John Chambers. The last version of S, called S4, came out in 1998. The R language was initially developed by Ross Ihaka and Robert Gentleman at the University of Auckland (in New Zealand) through clean-room methods. R was written to mimic S, but with its own code. The first official version of the R language was released in 1995 and version v1.0 in 2000. The current version of R is v4.1.1 (as of September 2021). R is a GNU package and is released under the GNU General Public License. The Comprehensive R Archive Network (CRAN) makes the language and packages available and is a network of mirrors at institutions. CRAN was first deployed in 1997. (The preceding information is from the Wikipedia pages