Margot Tollefson
Stratford, IA, USA
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484244043 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-4404-3 e-ISBN 978-1-4842-4405-0
https://doi.org/10.1007/978-1-4842-4405-0
Margot Tollefson 2019
Standard Apress
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction
R is a programming language that provides the user with powerful data and graphical analysis options. R is both flexible and broad. From tasks as simple as adding two numbers to tasks as complex as fitting an ARIMA model, R is capable of crunching the numbers.
The purpose of R Quick Syntax Reference is to provide the reader with the basic syntax of R. Often an R user gets stuck if, for example, a mode is incorrect or a logical test does not work. Because the full spectrum of R packages uses the same fairly simple syntax, R Quick Syntax Reference provides the reader with the necessary information to get unstuck and run and create all R functions and code.
The R language is based on the language S, a high-level programming language developed mainly by Richard A. Becker, John M. Chambers, and Allan R. Wilks in the AT&T laboratories in 1975. The R version of the language first became available in 1993 and was developed by Ross Ihaka and Robert Gentleman at the University of Auckland , New Zealand.
R is open source and is a GNU project . As open-source code, the R language is free and constantly being improved. The R Foundation for Statistical Computing maintains the program, and the R Development Core Team currently does the development. Packages for specific analysis techniques are added often. At the present time, there are over 10,000 packages available in R. Most users will use only a few packages. We discuss using R at the command prompt in R Quick Syntax Reference. We also cover the integrated development environment (IDE), R Studio. RStudio was founded by J.J. Allaire and became available in a beta version in 2011 and as a regular version in 2017. The Chief Scientist at R Studio is Hadley Wickham.
This book is about the S3 and S4 versions of R S3 and S4 standing for the third and fourth versions of S, the commercial program on which R is based. The two versions run concurrently. Even though version S4 is quite different from S3, it is necessary to know the syntax of S3 in order to use S4. And S3 remains a powerful, flexible language in its own righthence, this book.
Part I covers the basics of R. Chapter gives instructions for running R and R Studio from different folders. It also gives the methods for updating the R and R Studio programs themselves.
Chapter covers the assignment of names to objects, demonstrates the ls() function that allows you to see the objects in a folder, and discusses the operators in R and R Studio.
Part II describes R objects. Objects have modes, classes, and types. Chapter discusses some of the classes and how classes differ between S3 and S4 R.
Part III covers functions. Chapter explains how to run a functionwith a detailed approach to the argument list.
Part IV focuses on importing and exporting data in R and R Studio and methods for creating and manipulating some kinds of object. Chapter gives a number of functions that operate on objectsto bind objects together, to find descriptive qualities of an object, to assign qualities to an object, to aggregate an object in some way, or to apply functions to portions of an object.
Part V covers flow conditioning commands and functions. Chapter describes the two flow conditioning functions and gives examples.
Part VI discusses functions related to formatting and outputting output, looks at the results from packaged functions and at what some of the default packages contain, and provides some tips for using R and R Studio. Chapter describes how to deal with some common frustrations in R. More information is given on outputting from functions, plus an example of a recursive function and some advice on using R.
1. Downloading R and Setting Up a File System