Example: marketing

The R Book

The R Book The R Book Second Edition Michael J. Crawley Imperial College London at Silwood Park, UK. A John Wiley & Sons, Ltd., Publication This edition rst published 2013.. C 2013 John Wiley & Sons, Ltd Registered of ce John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, United Kingdom For details of our global editorial of ces, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at The right of the author to be identi ed as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.

2.13.4 Calculations with dates and times 105 2.13.5 The difftime and as.difftime functions 105 2.13.6 Generating sequences of dates 107 2.13.7 Calculating time differences between the rows of a dataframe 109 2.13.8 Regression using dates and times 111 2.13.9 Summary of dates and times in R 113 2.14 Environments 113 2.14.1 Using with rather than ...

Tags:

  Date, Using, Time, Dates and times, Using dates and times

Information

Domain:

Source:

Link to this page:

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

Other abuse

Transcription of The R Book

1 The R Book The R Book Second Edition Michael J. Crawley Imperial College London at Silwood Park, UK. A John Wiley & Sons, Ltd., Publication This edition rst published 2013.. C 2013 John Wiley & Sons, Ltd Registered of ce John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, United Kingdom For details of our global editorial of ces, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at The right of the author to be identi ed as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.

2 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Designations used by companies to distinguish their products are often claimed as trademarks.

3 All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.

4 Library of Congress Cataloging-in-Publication Data Crawley, Michael J. The R book / Michael J. Crawley. 2e. pages cm Includes bibliographical references and index. ISBN 978-0-470-97392-9 (hardback). 1. R (Computer program language) 2. Mathematical statistics Data processing. I. Title. 2013. 5133 dc23. 2012027339. A catalogue record for this book is available from the British Library. ISBN: 978-0-470-97392-9. Set in 10/12pt Times by Aptara Inc., New Delhi, India. Chapters Preface xxiii 1 Getting Started 1. 2 Essentials of the R Language 12.

5 3 Data Input 137. 4 Dataframes 159. 5 Graphics 189. 6 Tables 244. 7 Mathematics 258. 8 Classical Tests 344. 9 Statistical Modelling 388. 10 Regression 449. 11 Analysis of Variance 498. 12 Analysis of Covariance 537. 13 Generalized Linear Models 557. 14 Count Data 579. 15 Count Data in Tables 599. 16 Proportion Data 628. 17 Binary Response Variables 650. 18 Generalized Additive Models 666. 19 Mixed-Effects Models 681. 20 Non-Linear Regression 715. 21 Meta-Analysis 740. 22 Bayesian Statistics 752. vi CHAPTERS. 23 Tree Models 768. 24 time Series Analysis 785.

6 25 Multivariate Statistics 809. 26 Spatial Statistics 825. 27 Survival Analysis 869. 28 Simulation Models 893. 29 Changing the Look of Graphics 907. References and Further Reading 971. Index 977. Detailed Contents Preface xxiii 1 Getting Started 1. How to use this book 1. Beginner in both computing and statistics 1. Student needing help with project work 2. Done some R and some statistics, but keen to learn more of both 2. Done regression and ANOVA, but want to learn more advanced statistical modelling 2. Experienced in statistics, but a beginner in R 2.

7 Experienced in computing, but a beginner in R 2. Familiar with statistics and computing, but need a friendly reference manual 3. Installing R 3. Running R 3. The Comprehensive R Archive Network 4. Manuals 5. Frequently asked questions 5. Contributed documentation 5. Getting help in R 6. Worked examples of functions 6. Demonstrations of R functions 7. Packages in R 7. Contents of packages 8. Installing packages 8. Command line versus scripts 9. Data editor 9. Changing the look of the R screen 10. Good housekeeping 10. Linking to other computer languages 11.

8 2 Essentials of the R Language 12. Calculations 13. Complex numbers in R 13. Rounding 14. Arithmetic 16. Modulo and integer quotients 17. viii DETAILED CONTENTS. Variable names and assignment 18. Operators 19. Integers 19. Factors 20. Logical operations 22. TRUE and T with FALSE and F 22. Testing for equality with real numbers 23. Equality of oating point numbers using 23. Summarizing differences between objects using 24. Evaluation of combinations of TRUE and FALSE 25. Logical arithmetic 25. Generating sequences 27. Generating repeats 28.

9 Generating factor levels 29. Membership: Testing and coercing in R 30. Missing values, in nity and things that are not numbers 32. Missing values: NA 33. Vectors and subscripts 35. Extracting elements of a vector using subscripts 36. Classes of vector 38. Naming elements within vectors 38. Working with logical subscripts 39. Vector functions 41. Obtaining tables of means using tapply 42. The aggregate function for grouped summary statistics 44. Parallel minima and maxima: pmin and pmax 45. Summary information from vectors by groups 46.

10 Addresses within vectors 46. Finding closest values 47. Sorting, ranking and ordering 47. Understanding the difference between unique and duplicated 49. Looking for runs of numbers within vectors 50. Sets: union, intersect and setdiff 52. Matrices and arrays 53. Matrices 54. Naming the rows and columns of matrices 55. Calculations on rows or columns of the matrix 56. Adding rows and columns to the matrix 58. The sweep function 59. Applying functions with apply, sapply and lapply 61. using the function 65. Restructuring a multi-dimensional array using aperm 67.