Example: barber

An Introduction to R

An Introduction to RNotes on R: A Programming Environment for Data analysis and GraphicsVersion (2020-04-24)W. N. Venables, D. M. Smithand the R Core TeamThis manual is for R, version (2020-04-24).Copyrightc 1990 W. N. VenablesCopyrightc 1992 W. N. Venables & D. M. SmithCopyrightc 1997 R. Gentleman & R. IhakaCopyrightc 1997, 1998 M. MaechlerCopyrightc 1999 2018 R Core TeamPermission is granted to make and distribute verbatim copies of this manual providedthe copyright notice and this permission notice are preserved on all is granted to copy and distribute modified versions of this manual underthe conditions for verbatim copying, provided that the entire resulting derived workis distributed under the terms of a permission notice identical to this is granted to copy and distribute translations of this manual into an-other language, under the above conditions for modified versions, except that thispermission notice may be stated in a translation approved by the R Core of Introduction and The R Related software and R and R and the window Using R An introductory Getting help with functions and R commands, case sensitivity.

a suite of operators for calculations on arrays, in particular matrices, a large, coherent, integrated collection of intermediate tools for data analysis, graphical facilities for data analysis and display either directly at the computer or on hard-copy, and a well developed, simple and effective programming language (called ‘S’) which includes

Tags:

  Analysis, Introduction, Calculation

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of An Introduction to R

1 An Introduction to RNotes on R: A Programming Environment for Data analysis and GraphicsVersion (2020-04-24)W. N. Venables, D. M. Smithand the R Core TeamThis manual is for R, version (2020-04-24).Copyrightc 1990 W. N. VenablesCopyrightc 1992 W. N. Venables & D. M. SmithCopyrightc 1997 R. Gentleman & R. IhakaCopyrightc 1997, 1998 M. MaechlerCopyrightc 1999 2018 R Core TeamPermission is granted to make and distribute verbatim copies of this manual providedthe copyright notice and this permission notice are preserved on all is granted to copy and distribute modified versions of this manual underthe conditions for verbatim copying, provided that the entire resulting derived workis distributed under the terms of a permission notice identical to this is granted to copy and distribute translations of this manual into an-other language, under the above conditions for modified versions, except that thispermission notice may be stated in a translation approved by the R Core of Introduction and The R Related software and R and R and the window Using R An introductory Getting help with functions and R commands, case sensitivity.

2 Recall and correction of previous Executing commands from or diverting output to a Data permanency and removing Simple manipulations; numbers and Vectors and Vector Generating regular Logical Missing Character Index vectors; selecting and modifying subsets of a data Other types of Objects, their modes and Intrinsic attributes: mode and Changing the length of an Getting and setting The class of an Ordered and unordered A specific The functiontapply()and ragged Ordered Arrays and Array indexing. Subsections of an Index Thearray() Mixed vector and array arithmetic. The recycling The outer product of two Generalized transpose of an Matrix Matrix Linear equations and Eigenvalues and Singular value decomposition and Least squares fitting and the QR Forming partitioned matrices,cbind()andrbind().

3 The concatenation function,c(), with Frequency tables from Lists and data Constructing and modifying Concatenating Data Making data ()anddetach().. Working with data Attaching arbitrary Managing the search Reading data from () Thescan() Accessing builtin Loading data from other R Editing Probability R as a set of statistical Examining the distribution of a set of One- and two-sample Grouping, loops and conditional Grouped Control Conditional Repetitive execution:forloops, Writing your own Simple Defining new binary Named arguments and The .. Assignments within More advanced Efficiency factors in block Dropping all names in a printed Recursive numerical Customizing the Classes, generic functions and object Statistical models in Defining statistical models.

4 Linear Generic functions for extracting model analysis of variance and model ANOVA Updating fitted Generalized linear Theglm() Nonlinear least squares and maximum likelihood Least Maximum Some non-standard Graphical High-level plotting Theplot() Displaying multivariate Display Arguments to high-level plotting Low-level plotting Mathematical Hershey vector Interacting with Using graphics Permanent changes: Thepar() Temporary changes: Arguments to graphics Graphics parameters Graphical Axes and tick Figure Multiple figure Device PostScript diagrams for typeset Multiple graphics Dynamic Standard Contributed packages OS Files and System Compression and A A sample B Invoking Invoking R from the command Invoking R under Invoking R under Scripting with C The command-line Editing Command-line editor D Function and variable E Concept F Introduction to R is derived from an original set of notes describing the S andS-Plusenvironments written in 1990 2 by Bill Venables and David M.

5 Smith when at the Universityof Adelaide. We have made a number of small changes to reflect differences between the R andS programs, and expanded some of the would like to extend warm thanks to Bill Venables (and David Smith) for grantingpermission to distribute this modified version of the notes in this way, and for being a supporterof R from way and corrections are always welcome. Please address email correspondence to the readerMost R novices will start with the introductory session in Appendix A. This should give somefamiliarity with the style of R sessions and more importantly some instant feedback on whatactually users will come to R mainly for its graphical facilities. SeeChapter 12 [Graphics],page 63, which can be read at almost any time and need not wait until all the preceding sectionshave been Introduction and The R environmentR is an integrated suite of software facilities for data manipulation, calculation and graphicaldisplay.

6 Among other things it has an effective data handling and storage facility, a suite of operators for calculations on arrays, in particular matrices, a large, coherent, integrated collection of intermediate tools for data analysis , graphical facilities for data analysis and display either directly at the computer or on hard-copy, and a well developed, simple and effective programming language (called S ) which includesconditionals, loops, user defined recursive functions and input and output facilities. (Indeedmost of the system supplied functions are themselves written in the S language.)The term environment is intended to characterize it as a fully planned and coherent system,rather than an incremental accretion of very specific and inflexible tools, as is frequently thecase with other data analysis is very much a vehicle for newly developing methods of interactive data analysis . It hasdeveloped rapidly, and has been extended by a large collection ofpackages.

7 However, mostprograms written in R are essentially ephemeral, written for a single piece of data Related software and documentationR can be regarded as an implementation of the S language which was developed at Bell Labora-tories by Rick Becker, John Chambers and Allan Wilks, and also forms the basis of evolution of the S language is characterized by four books by John Chambers andcoauthors. For R, the basic reference isThe New S Language: A Programming Environmentfor Data analysis and Graphicsby Richard A. Becker, John M. Chambers and Allan R. new features of the 1991 release of S are covered inStatistical Models in Sedited by JohnM. Chambers and Trevor J. Hastie. The formal methods and classes of themethodspackage arebased on those described inProgramming with Databy John M. Chambers. SeeAppendix F[References], page 99, for precise are now a number of books which describe how to use R for data analysis and statistics,and documentation for S/S-Pluscan typically be used with R, keeping the differences betweenthe S implementations in mind.

8 SeeSection What documentation exists for R? inThe Rstatistical system R and statisticsOur Introduction to the R environment did not mentionstatistics, yet many people use R as astatistics system. We prefer to think of it of an environment within which many classical andmodern statistical techniques have been implemented. A few of these are built into the base Renvironment, but many are supplied aspackages. There are about 25 packages supplied withR (called standard and recommended packages) and many more are available through theCRAN family of Internet sites ( ) and elsewhere. More detailson packages are given later (seeChapter 13 [Packages], page 77).Most classical statistics and much of the latest methodology is available for use with R, butusers may need to be prepared to do a little work to find 1: Introduction and preliminaries3 There is an important difference in philosophy between S (and hence R) and the othermain statistical systems.

9 In S a statistical analysis is normally done as a series of steps, withintermediate results being stored in objects. Thus whereas SAS and SPSS will give copiousoutput from a regression or discriminant analysis , R will give minimal output and store theresults in a fit object for subsequent interrogation by further R R and the window systemThe most convenient way to use R is at a graphics workstation running a windowing guide is aimed at users who have this facility. In particular we will occasionally refer tothe use of R on an X window system although the vast bulk of what is said applies generally toany implementation of the R users will find it necessary to interact directly with the operating system on theircomputer from time to time. In this guide, we mainly discuss interaction with the operatingsystem on UNIX machines. If you are running R under Windows or macOS you will need tomake some small up a workstation to take full advantage of the customizable features of R is a straight-forward if somewhat tedious procedure, and will not be considered further here.

10 Users in diffi-culty should seek local expert Using R interactivelyWhen you use the R program it issues a prompt when it expects input commands. The defaultprompt is > , which on UNIX might be the same as the shell prompt, and so it may appear thatnothing is happening. However, as we shall see, it is easy to change to a different R prompt ifyou wish. We will assume that the UNIX shell prompt is $ .In using R under UNIX the suggested procedure for the first occasion is as follows:1. Create a separate sub-directory, saywork, to hold data files on which you will use R forthis problem. This will be the working directory whenever you use R for this particularproblem.$ mkdir work$ cd work2. Start the R program with the command$ R3. At this point R commands may be issued (see later).4. To quit the R program the command is> q()At this point you will be asked whether you want to save the data from your R session. Onsome systems this will bring up a dialog box, and on others you will receive a text promptto which you can respondyes,noorcancel(a single letter abbreviation will do) to savethe data before quitting, quit without saving, or return to the R session.


Related search queries