Giter VIP home page Giter VIP logo

getting-and-cleaning-data-project's Introduction

Getting and Cleaning Data Project

run_analysis.R

The cleanup script (run_analysis.R) does the following:

  1. Merges the training and the test sets to create one data set.
  2. Extracts only the measurements on the mean and standard deviation for each measurement.
  3. Uses descriptive activity names to name the activities in the data set
  4. Appropriately labels the data set with descriptive activity names.
  5. Creates a second, independent tidy data set with the average of each variable for each activity and each subject.

Running the script

To run the script, source run_analysis.R. After running, you will see the following output as the script works:

[run_analysis.R] Getting and Cleaning Data Project 
[run_analysis.R] Author: William Bowers 
[run_analysis.R] --- 
[run_analysis.R] Starting up. 
[run_analysis.R] Preparing to run analysis. 
[run_analysis.R] Reading datasets. 
[run_analysis.R] Getting dataset: /repos/Getting-and-Cleaning-Data-Project/data/test 
[run_analysis.R]   reading features... 
[run_analysis.R]   reading activities... 
[run_analysis.R]   reading subjects... 
[run_analysis.R] Getting dataset: /repos/Getting-and-Cleaning-Data-Project/data/train 
[run_analysis.R]   reading features... 
[run_analysis.R]   reading activities... 
[run_analysis.R]   reading subjects... 
[run_analysis.R] Joining datasets. 
[run_analysis.R] Melting. 
[run_analysis.R] Dcasting. 
[run_analysis.R] Saving clean data to: /repos/Getting-and-Cleaning-Data-Project/data/cleaned.txt 

Process

  1. For both the test and train datasets, produce an interim dataset:
    1. Extract the mean and standard deviation features (listed in CodeBook.md, section 'Extracted Features'). This is the values table.
    2. Get the list of activities.
    3. Put the activity labels (not numbers) into the values table.
    4. Get the list of subjects.
    5. Put the subject IDs into the values table.
  2. Join the test and train interim datasets.
  3. Put each variable on its own row.
  4. Rejoin the entire table, keying on subject/acitivity pairs, applying the mean function to each vector of values in each subject/activity pair. This is the clean dataset.
  5. Write the clean dataset to disk.

Cleaned Data

The resulting clean dataset is in this repository at: data/cleaned.txt. It contains one row for each subject/activity pair and columns for subject, activity, and each feature that was a mean or standard deviation from the original dataset.

Notes

X_* - feature values (one row of 561 features for a single activity) Y_* - activity identifiers (for each row in X_) subject_ - subject identifiers for rows in X_*

getting-and-cleaning-data-project's People

Contributors

wbowers-coursera avatar willurd avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.