Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Practical Predictive Analytics

You're reading from   Practical Predictive Analytics Analyse current and historical data to predict future trends using R, Spark, and more

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781785886188
Length 576 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ralph Winters Ralph Winters
Author Profile Icon Ralph Winters
Ralph Winters
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Predictive Analytics FREE CHAPTER 2. The Modeling Process 3. Inputting and Exploring Data 4. Introduction to Regression Algorithms 5. Introduction to Decision Trees, Clustering, and SVM 6. Using Survival Analysis to Predict and Analyze Customer Churn 7. Using Market Basket Analysis as a Recommender Engine 8. Exploring Health Care Enrollment Data as a Time Series 9. Introduction to Spark Using R 10. Exploring Large Datasets Using Spark 11. Spark Machine Learning - Regression and Cluster Models 12. Spark Models – Rule-Based Learning

Getting started with RStudio

After R installation has completed, point your browser to the download section found through the RStudio web site (https://www.rstudio.com/) and install the RStudio executable appropriate for your operating system:

  • Click the RStudio icon to bring up the program.
  • The program initially starts with three tiled window panes, as shown in the following screenshot. If the layout does not correspond exactly to what is shown, the next section will show you how to rearrange the layout to correspond with the examples shown in this chapter:

Rearranging the layout to correspond with the examples

To rearrange the layout, see the following steps:

  1. Select Tools | Global Options | Pane Layout from the top navigation bar.
  2. Select the drop-down arrow in each of the four quadrants, and change the title of each pane to what is shown in the following diagram.
    • Make sure that Environment | History | Files | Plots and Help are selected for the upper left pane
    • Make sure that Viewer is selected for the bottom left pane.
    • Select Console for the bottom right pane
    • Select Source for the upper right pane
  3. Click OK.

After the changes are applied the layout should more closely match the layout previously shown . However, it may not match exactly. A lot will depend upon the version of RStudio that you are using as well as the packages you may have already installed.

Brief description of some important panes

  • The Source pane will be used to code and save your programs. Once code is created you can use File | Save to save your work to an external file, and File |Open to retrieve the saved code.
If you are installing RStudio for the first time nothing may be shown as the fourth pane. However, as you create new programs (as we will later in this chapter), it will appear in the upper right quadrant.
  • The Console pane provides important feedback and information about your program after it has been run. It will show you any syntax or error messages that have occurred. It is always a best practice to examine the console to make sure you are getting the results you expect, and make sure the console is clear of errors. The console is also the place that you will see a lots of output which has been created from your programs.
  • We will rely heavily on the View pane. This pane displays formatted output which is run by using the R View command.
  • The Environment | History | Plots pane is sort of a catch-all pane which changes functions depending upon what which tabs have been selected via the pane layout dialogue. For example, all plots issued by R command are displayed under the Plots tab. Help is always a click away by selecting the Help tab. There is also a useful tab called Packages which will automatically load a package, when a particular package is checked.

Creating a new project

Once you are set with your layout, proceed to create a new project by following these steps:

Create a new project by following these steps:

  1. Identify the menu bar, above the icons at the top left of the screen.
  2. Click File and then New Project
  3. At the next screen select Existing Directory:
  1. The following screen will appear:
  1. The Project working directory is initial populated with a tilde (~). This means that the project will be created in the directory you are currently in.
  2. To specify the directory first select Browse, and then navigate to the PracticalPredictiveAnalytics folder you created in the previous steps.
  3. When the Choose Directory dialog box appear, select this directory using the Select Folder button.
  4. After selecting the directory, the following should appear (Windows only):
  1. To finalize creating the project, Select the Create Project button. Rstudio will then switch to the new project you have just created.

All screen panes will then appear as blank (except for the log), and the title bar at the top left of the screen will show the path to the project.

To verify that the R, outputs, and data directories are contained within the project, select File, and then File Open from the top menu bar. The three folders should appear, as indicated as follows:

Once you have verified this, cancel the Open File dialogue, and return to RStudio main screen.

You have been reading a chapter from
Practical Predictive Analytics
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781785886188
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime