Learning R Programming
eBook - ePub

Learning R Programming

Kun Ren

Share book
  1. 582 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning R Programming

Kun Ren

Book details
Book preview
Table of contents
Citations

About This Book

Become an efficient data scientist with R

About This Book

  • Explore the R language from basic types and data structures to advanced topics
  • Learn how to tackle programming problems and explore both functional and object-oriented programming techniques
  • Learn how to address the core problems of programming in R and leverage the most popular packages for common tasks

Who This Book Is For

This is the perfect tutorial for anyone who is new to statistical programming and modeling. Anyone with basic programming and data processing skills can pick this book up to systematically learn the R programming language and crucial techniques.

What You Will Learn

  • Explore the basic functions in R and familiarize yourself with common data structures
  • Work with data in R using basic functions of statistics, data mining, data visualization, root solving, and optimization
  • Get acquainted with R's evaluation model with environments and meta-programming techniques with symbol, call, formula, and expression
  • Get to grips with object-oriented programming in R: including the S3, S4, RC, and R6 systems
  • Access relational databases such as SQLite and non-relational databases such as MongoDB and Redis
  • Get to know high performance computing techniques such as parallel computing and Rcpp
  • Use web scraping techniques to extract information
  • Create RMarkdown, an interactive app with Shiny, DiagramR, interactive charts, ggvis, and more

In Detail

R is a high-level functional language and one of the must-know tools for data science and statistics. Powerful but complex, R can be challenging for beginners and those unfamiliar with its unique behaviors. Learning R Programming is the solution - an easy and practical way to learn R and develop a broad and consistent understanding of the language. Through hands-on examples you'll discover powerful R tools, and R best practices that will give you a deeper understanding of working with data. You'll get to grips with R's data structures and data processing techniques, as well as the most popular R packages to boost your productivity from the offset.

Start with the basics of R, then dive deep into the programming techniques and paradigms to make your R code excel. Advance quickly to a deeper understanding of R's behavior as you learn common tasks including data analysis, databases, web scraping, high performance computing, and writing documents. By the end of the book, you'll be a confident R programmer adept at solving problems with the right techniques.

Style and approach

Developed to make learning easy and intuitive, this book comes packed with a wide variety of statistical and graphical techniques and a wealth of practical information for anyone looking to get started with this exciting and powerful language.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning R Programming an online PDF/ePUB?
Yes, you can access Learning R Programming by Kun Ren in PDF and/or ePUB format, as well as other popular books in Computer Science & Software Development. We have over one million books available in our catalogue for you to explore.

Information

Year
2016
ISBN
9781785889776

Learning R Programming


Learning R Programming

Copyright Š 2016 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: October 2016
Production reference: 1181016
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-977-6
www.packtpub.com

Credits

Author
Kun Ren
Copy Editor
Karuna Narayanan
Reviewer
Kelly Black
Project Coordinator
Izzat Contractor
Commissioning Editor
Akram Hussain
Proofreader
Safis Editing
Acquisition Editor
Denim Pinto
Indexer
Tejal Daruwale Soni
Content Development Editor
Rohit Kumar Singh
Graphics
Kirk D'Penha
Disha Haria
Jason Monteiro
Technical Editor
Vivek Pala
Production Coordinator
Melwyn D'sa

About the Author

Kun Ren has used R for nearly 4 years in quantitative trading, along with C++ and C#, and he has worked very intensively (more than 8-10 hours every day) on useful R packages that the community does not offer yet. He contributes to packages developed by other authors and reports issues to make things work better. He is also a frequent speaker at R conferences in China and has given multiple talks. Kun also has a great social media presence. Additionally, he has substantially contributed to various projects, which is evident from his GitHub account:
  • https://github.com/renkun-ken
  • https://cn.linkedin.com/in/kun-ren-76027530
  • http://renkun.me/
  • http://renkun.me/formattable/
  • http://renkun.me/pipeR/
  • http://renkun.me/rlist/
I would like to thank my wife, who encouraged me to start working on this book a year ago, and my parents, who support me with unconditional love. I would also like to express my gratitude to the editors, Rohit Kumar Singh, Vivek Pala, and those who also worked hard on this book. They did a great job making the writing and publishing smooth.

About the Reviewer

Kelly Black is a member of the department of mathematics at the University of Georgia. His focus is stochastic differential equations, and he makes use of statistical software in a wide range of contexts, ranging from data analysis from Monte Carlo simulations to educational assessment.
I am grateful for the kindness and patience of Izzat Contractor, who helped guide the final production of this book.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.
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.PacktPub.com
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

  • Fully searchable across every book published by Packt
  • Copy and paste, print, and bookmark content
  • On demand and accessible via a web browser

Preface

R is designed for statistical computing, data analysis, and visualization. In recent years, it has become the most popular language for data science and statistics. R programming heavily involves data processing and it can be a challenge to program in R for those who are unfamiliar with the behaviors of the R language.
As a dynamic language, R allows extremely flexible use of data structures that are not as strict as compiled languages, such as C++, Java, and C#. When I started using R to process and analyze data, I found R’s behavior quirky, unpredictable, and sometimes very inconsistent.
In those data analysis projects, most effort was not spent running models. Instead, data cleaning, wrangling, and visualization took a major part of my time. In fact, it is most time consuming to find what’s wrong with the code that produced weird results or died in unexpected errors. Dealing with programming rather than field problems can be frustrating, especially when you have fought against bugs for hours without a clue.
However, as I work on more projects and gain more experience, I gradually know more about the behavior of objects and functions, and find that R is much more beautiful and consistent than I thought. That’s why I've written this book—to share my perspective on programming in R.
Through this book, you will develop a universal and consistent understanding of R as a programming language along with its vast set of tools. You will learn the best practices to boost your productivity, develop a deeper understanding of working with data, and become more confident about programming in R and solving problems with the right techniques.

What this book covers

Chapter 1, Quick Start, discusses a few basic facts about R, how to deploy an R environment, and how to code in RStudio.
Chapter 2, Basic Objects, introduces basic R objects and their behaviors.
Chapter 3, Managing Your Workspace, introduces the methods of managing the working directory, R environment, and the library of extension packages.
Chapter 4, Basic Expressions, covers the basic expressions of the R language: assignment, condition, and loop.
Chapter 5, Working with Basic Objects, discusses the basic functions each analyst should know in order to work with basic objects in R.
Chapter 6, Working with Strings, talks about R objects related with strings, and a number of string manipulation techniques.
Chapter 7, Working with Data, explains simple read/write data functions with some practical examples on various topics using basic objects and functions.
Chapter 8, Inside R, discusses R’s evaluation model by introducing what lazy evaluation, environment, function, and lexical scoping work is.
Chapter 9, Metaprogramming, introduces the metaprogramming techniques to help understand language objects and nonstandard evaluation.
Chapter 10, Object-Oriented Programming, describes the numerous object-oriented programming systems in R: S3, S4, RefClass, and community-provided R6.
Chapter 11, Working with Databases, shows how R works with popular relational databases such as SQLite and MySQL, and non-relational databases such as MongoDB and Redis.
Chapter 12, Data Manipulation, introduces techniques of manipulating relational data using data.table and dplyr, and non-relational data using rlist.
Chapter 13, High Performance Computing, discusses performance issues in R and several methods to boost computing performance.
Chapter 14, Web Scraping, talks about the basic structure of web pages, CSS, and XPath selectors and how to use the rvest package to scrape data from simple web pages.
Chapter 15, Boosting Productivity, demonstrates how R Markdown an...

Table of contents