You are previewing Exploring Everyday Things with R and Ruby.
O'Reilly logo
Exploring Everyday Things with R and Ruby

Book Description

If you’re curious about how things work, this fun and intriguing guide will help you find real answers to everyday problems. By using fundamental math and doing simple programming with the Ruby and R languages, you’ll learn how to model a problem and work toward a solution. All you need is a basic understanding of programming. After a quick introduction to Ruby and R, you’ll explore a wide range of questions by learning how to assemble, process, simulate, and analyze the available data.

Table of Contents

  1. Exploring Everyday Things with R and Ruby
  2. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  3. Preface
    1. Explorers Ahoy!
    2. Data, Data, Everywhere
    3. Bringing the World to Us
    4. Packing Your Bags
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
    9. Acknowledgments
  4. 1. The Hat and the Whip
    1. Ruby
      1. Why Ruby
      2. Installing Ruby
        1. Installing Ruby from source
        2. Installing Ruby using third-party tools
          1. Ruby Version Manager (RVM)
          2. RubyInstaller
        3. Installing Ruby using your platform’s package management tool
      3. Running Ruby
      4. Requiring External Libraries
      5. Basic Ruby
        1. Strings
        2. Arrays and hashes
        3. Symbols
        4. Conditionals and loops
          1. if and unless
          2. case expression
          3. Loops
      6. Everything Is an Object
        1. Classes and objects
        2. Methods
        3. Class methods and variables
        4. Inheritance
        5. Code like a duck
    2. Shoes
      1. What Is Shoes?
      2. A Rainbow of Shoes
      3. Installing Shoes
      4. Programming Shoes
        1. Shoes stopwatch
        2. Shoes doodler
    3. Wrap-up
  5. 2. Into the Matrix
    1. Introducing R
    2. Using R
      1. The R Console
      2. Sourcing Files and the Command Line
      3. Packages
        1. Installing packages
        2. Using packages
    3. Programming R
      1. Variables and Functions
      2. Conditionals and Loops
      3. Data Structures
        1. Vectors
        2. Lists
        3. Matrices
        4. Arrays
        5. Factors
        6. Data frames
      4. Importing Data
        1. Importing data from text files
        2. Importing data from a database
    4. Charting
      1. Basic Graphs
        1. Plotting charts
      2. Introducing ggplot2
        1. qplot
        2. Using the grammar
        3. Plot
        4. Aesthetics
        5. Statistical transformation
        6. Geometric object
        7. Adjustments
    5. Wrap-up
  6. 3. Offices and Restrooms
    1. The Simple Scenario
    2. Representing Restrooms and Such
    3. The First Simulation
    4. Interpreting the Data
    5. The Second Simulation
    6. The Third Simulation
    7. The Final Simulation
    8. Wrap-up
  7. 4. How to Be an Armchair Economist
    1. The Invisible Hand
    2. A Simple Market Economy
      1. The Producer
      2. The Consumer
      3. Some Convenience Methods
      4. The Simulation
      5. Analyzing the Simulation
    3. Resource Allocation by Price
      1. The Producer
      2. The Consumer
      3. Market
      4. The Simulation
      5. Analyzing the Second Simulation
      6. Price Controls
    4. Wrap-up
  8. 5. Discover Yourself Through Email
    1. The Idea
    2. Grab and Parse
      1. The Emailing Habits of Enron Executives
    3. Discover Yourself
      1. Number of Messages by Day of the Month
      2. MailMiner
      3. Number of Messages by Day of Week
      4. Number of Messages by Month
      5. Number of Messages by Hour of the Day
      6. Interactions
      7. Comparative Interactions
    4. Text Mining
    5. Wrap-up
  9. 6. In a Heartbeat
    1. My Beating Heart
    2. Auscultation
      1. Homemade Digital Stethoscope
      2. Extracting Data from Sound
      3. Generating the Heart Sounds Waveform
      4. Finding the Heart Rate
    3. Oximetry
      1. Homemade Pulse Oximeter
      2. Extracting Data from Video
      3. Generating the Heartbeat Waveform and Calculating the Heart Rate
    4. Wrap-up
  10. 7. Schooling Fish and Flocking Birds
    1. The Origin of Boids
    2. Simulation
    3. Roids
    4. The Boid Flocking Rules
    5. Supporting Rules
    6. A Variation on the Rules
    7. Going Round and Round
    8. Putting in Obstacles
    9. Wrap-up
  11. 8. Money, Sex, and Evolution
    1. It’s a Good Life
    2. Money
    3. Sex
      1. Birth and Death
      2. The Changes
    4. Evolution
      1. What We Will Be Changing
      2. Implementation
    5. Wrap-up
  12. Index
  13. About the Author
  14. Colophon
  15. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  16. Copyright