You are previewing RStudio for R Statistical Computing Cookbook.
O'Reilly logo
RStudio for R Statistical Computing Cookbook

Book Description

Over 50 practical and useful recipes to help you perform data analysis with R by unleashing every native RStudio feature

About This Book

  • 54 useful and practical tasks to improve working systems

  • Includes optimizing performance and reliability or uptime, reporting, system management tools, interfacing to standard data ports, and so on

  • Offers 10-15 real-life, practical improvements for each user type

  • Who This Book Is For

    This book is targeted at R statisticians, data scientists, and R programmers. Readers with R experience who are looking to take the plunge into statistical computing will find this Cookbook particularly indispensable.

    What You Will Learn

  • Familiarize yourself with the latest advanced R console features

  • Create advanced and interactive graphics

  • Manage your R project and project files effectively

  • Perform reproducible statistical analyses in your R projects

  • Use RStudio to design predictive models for a specific domain-based application

  • Use RStudio to effectively communicate your analyses results and even publish them to a blog

  • Put yourself on the frontiers of data science and data monetization in R with all the tools that are needed to effectively communicate your results and even transform your work into a data product

  • In Detail

    The requirement of handling complex datasets, performing unprecedented statistical analysis, and providing real-time visualizations to businesses has concerned statisticians and analysts across the globe. RStudio is a useful and powerful tool for statistical analysis that harnesses the power of R for computational statistics, visualization, and data science, in an integrated development environment.

    This book is a collection of recipes that will help you learn and understand RStudio features so that you can effectively perform statistical analysis and reporting, code editing, and R development. The first few chapters will teach you how to set up your own data analysis project in RStudio, acquire data from different data sources, and manipulate and clean data for analysis and visualization purposes. You'll get hands-on with various data visualization methods using ggplot2, and you will create interactive and multidimensional visualizations with D3.js. Additional recipes will help you optimize your code; implement various statistical models to manage large datasets; perform text analysis and predictive analysis; and master time series analysis, machine learning, forecasting; and so on. In the final few chapters, you'll learn how to create reports from your analytical application with the full range of static and dynamic reporting tools that are available in RStudio so that you can effectively communicate results and even transform them into interactive web applications.

    Style and approach

    RStudio is an open source Integrated Development Environment (IDE) for the R platform. The R programming language is used for statistical computing and graphics, which RStudio facilitates and enhances through its integrated environment.

    This Cookbook will help you learn to write better R code using the advanced features of the R programming language using RStudio. Readers will learn advanced R techniques to compute the language and control object evaluation within R functions. Some of the contents are:

  • Accessing an API with R

  • Substituting missing values by interpolation

  • Performing data filtering activities

  • R Statistical implementation for Geospatial data

  • Developing shiny add-ins to expand RStudio functionalities

  • Using GitHub with RStudio

  • Modelling a recommendation engine with R

  • Using R Markdown for static and dynamic reporting

  • Curating a blog through RStudio

  • Advanced statistical modelling with R and RStudio

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. RStudio for R Statistical Computing Cookbook
      1. Table of Contents
      2. RStudio for R Statistical Computing Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why Subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Acquiring Data for Your Project
        1. Introduction
        2. Acquiring data from the Web – web scraping tasks
          1. Getting ready
          2. How to do it...
          3. There's more...
        3. Accessing an API with R
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
        4. Getting data from Twitter with the twitteR package
          1. Getting ready
          2. How to do it…
          3. There's more...
        5. Getting data from Facebook with the Rfacebook package
          1. Getting ready
          2. How to do it...
        6. Getting data from Google Analytics
          1. Getting ready
          2. How to do it...
          3. There's more...
        7. Loading your data into R with rio packages
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        8. Converting file formats using the rio package
          1. Getting ready
          2. How to do it...
          3. There's more...
      9. 2. Preparing for Analysis – Data Cleansing and Manipulation
        1. Introduction
        2. Getting a sense of your data structure with R
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Preparing your data for analysis with the tidyr package
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Detecting and removing missing values
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Substituting missing values using the mice package
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Detecting and removing outliers
          1. How to do it...
          2. How it works...
        7. Performing data filtering activities
          1. Getting ready
          2. How to do it…
          3. How it works...
      10. 3. Basic Visualization Techniques
        1. Introduction
        2. Looking at your data using the plot() function
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Using pairs.panel() to look at (visualize) correlations between variables
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more…
        4. Adding text to a ggplot2 plot at a custom location
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more…
        5. Changing axes appearance to ggplot2 plot (continous axes)
          1. Getting ready
          2. How to do it...
        6. Producing a matrix of graphs with ggplot2
          1. Getting ready
          2. How to do it...
          3. How it works…
        7. Drawing a route on a map with ggmap
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. See also
        8. Making use of the igraph package to draw a network
          1. Getting ready
          2. How to do it...
          3. How it works…
        9. Showing communities in a network with the linkcomm package
          1. Getting ready
          2. How to do it…
          3. How it works…
      11. 4. Advanced and Interactive Visualization
        1. Introduction
        2. Producing a Sankey diagram with the networkD3 package
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Creating a dynamic force network with the visNetwork package
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Building a rotating 3D graph and exporting it as a GIF
          1. Getting ready
          2. How to do it...
        5. Using the DiagrammeR package to produce a process flow diagram in RStudio
          1. Getting ready
          2. How to do it...
      12. 5. Power Programming with R
        1. Introduction
        2. Writing modular code in RStudio
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Implementing parallel computation in R
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Creating custom objects and methods in R using the S3 system
          1. How to do it...
          2. How it works...
        5. Evaluating your code performance using the profvis package
          1. Getting ready
          2. How to do it...
        6. Comparing an alternative function's performance using the microbenchmarking package
          1. Getting ready
          2. How to do it...
        7. Using GitHub with RStudio
          1. Getting ready
          2. How to do it...
          3. There's more...
      13. 6. Domain-specific Applications
        1. Introduction
        2. Dealing with regular expressions
          1. How to do it...
        3. Analyzing PDF reports in a folder with the tm package
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Creating word clouds with the wordcloud package
          1. Getting ready
          2. How to do it...
          3. How it works...
        5. Performing a Twitter sentiment analysis
          1. Getting ready
          2. How to do it...
          3. How it works...
        6. Detecting fraud in e-commerce orders with Benford's law
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Measuring customer retention using cohort analysis in R
          1. Getting ready
          2. How to do it...
          3. How it works...
        8. Making a recommendation engine
          1. Getting ready
          2. How to do it...
        9. Performing time series decomposition using the stl() function
          1. Getting ready
          2. How to do it...
        10. Exploring time series forecasting with forecast()
          1. Getting ready
          2. How to do it...
        11. Tracking stock movements using the quantmod package
          1. Getting ready
          2. How to do it...
        12. Optimizing portfolio composition and maximising returns with the Portfolio Analytics package
          1. Getting ready
          2. How to do it...
        13. Forecasting the stock market
          1. Getting ready
          2. How to do it...
      14. 7. Developing Static Reports
        1. Introduction
        2. Using one markup language for all types of documents – rmarkdown
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There’s more...
        3. Writing and styling PDF documents with RStudio
          1. Getting ready
          2. How to do it...
          3. There’s more...
        4. Writing wonderful tufte handouts with the tufte package and rmarkdown
          1. Getting ready
          2. How to do it...
          3. There’s more...
        5. Sharing your code and plots with slides
          1. How to do it...
        6. Curating a blog through RStudio
          1. Getting ready
          2. How to do it...
      15. 8. Dynamic Reporting and Web Application Development
        1. Introduction
        2. Generating dynamic parametrized reports with R Markdown
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more…
        3. Developing a single-file Shiny app
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Changing a Shiny app UI based on user input
          1. Getting ready
          2. How to do it...
          3. See also
        5. Creating an interactive report with Shiny
          1. How to do it…
          2. How it works...
          3. See also
        6. Constructing RStudio add-ins
          1. Getting ready
          2. How to do it...
          3. There's more…
        7. Sharing your work on RPubs
          1. Getting ready
          2. How to do it...
          3. There's more…
        8. Deploying your app on Amazon AWS with ramazon
          1. Getting ready
          2. How to do it...
      16. Index