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

The R console

Now that we have created a project, let us take a look at the R Console window. Click on the window marked Console. All console commands are issued by typing your command following the command prompt >, and then pressing Enter. I will just illustrate three commands that will help you answer the questions "Which project am I on?", and "What files do I have in my folders?"

  1. getwd(): The getwd() command is very important since it will always tell you which directory you are in. Since we just created a new project, we expect that we will be pointing to the directory we just created, right?
    To double check, switch over to the console, issue the getwd() command, and then press Enter. That should echo back the current working directory:
  1. dir(): The dir() command will give you a list of all files in the current working directory. In our case, it is simply the names of the three directories you have just created. However, typically may see many files, usually corresponding to the type of directory you are in (.R for source files, .dat, .csv for data files, and so on):
  1. setwd(): Sometimes you will need to switch directories within the same project or even to another project. The command you will use is setwd(). You will supply the directory that you want to switch to, all contained within the parentheses.
    Here is an example which will switch to the sub-directory which will house the R code. This particular example supplies the entire path as the directory destination. Since you are already in the PracticalPredictiveAnalytics directory, you can also use setwd(“R”) which accomplishes the same thing:
        > setwd("C:/PracticalPredictiveAnalytics/R")

To verify that it has changed, issue the getwd() command again:

        > getwd()
[1] "C:/PracticalPredictiveAnalytics/R"

I suggest using getwd() and setwd() liberally, especially if you are working on multiple projects, and want to avoid reading or writing the wrong files.

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 €18.99/month. Cancel anytime