www.it-ebooks.info Instant R Starter Jump into the R programming language and go beyond "Hello World!" Donato Teutonico, PhD BIRMINGHAM - MUMBAI www.it-ebooks.info Instant R Starter Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: April 2013 Production Reference: 1170413 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78216-350-3 www.packtpub.com www.it-ebooks.info Credits Author Copy Editor Donato Teutonico Alfida Paiva Reviewers Project Coordinator Manjusha S. Joshi Sherin Padayatty Tengfei Yin Proofreader Acquisition Editor Paul Hindle Joanna Finchen Production Coordinator Commissioning Editor Manu Joseph Sharvari Tawde Cover Work Technical Editors Manu Joseph Chirag Jani Devdutt Kulkarni Cover Image Veena Pagare Conidon Miranda www.it-ebooks.info About the Author Donato Teutonico has several years of experience in modeling and simulation of drug effects and clinical trials in industrial and academic settings. He received his PharmD degree from the University of Turin, Italy, with a specialization in Chemical and Pharmaceutical Technology, and received his Ph.D. in Pharmaceutical Sciences from the Paris-South University, France. He is the author of two R packages for Pharmacometrics; CTStemplate and panels4Pharmacometrics; both are available on Google code. A big thanks to my wife Raquel for all her support during the preparation of this book www.it-ebooks.info About the Reviewers Manjusha S. Joshi is a mathematician who studied at the University of Pune. She has worked as a Principal Investigator for the project Use of Open Source Software for Teaching Mathematics, supported by MHRD, Govt. of India, conducted at Bhaskaracharya Pratishthana, a research institute of Mathematics. Manjusha is an open-source software enthusiast and is interested in promotion of open-source software for higher studies. She has conducted a few courses on R programming at the University of Pune and some other places. www.it-ebooks.info www.packtpub.com Support files, eBooks, discount offers and more You might want to visit www.packtpub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packtpub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.packtpub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. www.it-ebooks.info packtlib.packtpub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? Ê Fully searchable across every book published by Packt Ê Copy and paste, print and bookmark content Ê On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.packtpub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. TM www.it-ebooks.info www.it-ebooks.info Table of Contents Instant R Starter 1 So, what is R? 1 Getting help 1 R packages 2 Installation 3 Step 1 – obtaining and installing R 3 Binary distribution 3 Installation from source 3 Step 2 – R versions 4 Step 3 – news 4 Step 4 – package installation 4 Step 5 – using Integrated Development Environment for R 5 RStudio 5 Eclipse 6 Emacs 7 Quick start – R language 8 Step 1 – interacting with the console 8 Starting R 8 Basics of the R language 10 Function arguments 11 Built-in data 11 Special values (NA, NaN, Inf) 11 Logical expressions 12 Step 2 – understanding R objects 13 Vectors 13 Working with vectors 14 Matrices and arrays 15 Lists 17 Data frame 18 www.it-ebooks.info