Giter Club home page Giter Club logo

g-cd_project's Introduction

Getting and Cleaning Data Course project

How to use the run_analysis.R script:

This script is capable of downloading the UCI HAR Dataset from the url source provided for the project. If the zipped dataset is found in the working directory (UCI HAR Dataset.zip) it will extract the necessary information from within the zip file itself. The only thing needed is a working directory, or a working directory with the original zipped dataset file.

What this script does:

After locating the zipped dataset archive the following datasets are created

|Dataset Name |                         Description                                     |  
|:------------|:-----------------------------------------------------------------------:|  
|activity     | contains the list of activity labels from the activity_labels.txt file  |    
|variables    | contains the variable names from the features.txt file                  |  
|xtrain       | contains the actual data values from the X_train.txt file               |  
|ytrain       | contains the activity id's from y_train.txt file                        |
|subject      | contains the subject identifier from the subject_train.txt file         |  

Processing begins by looping thru the ytrain dataframe activity id's and replacing them with activity labels. Next we replace the default column names, subjectid for the subject dataframe, variable names from the variables dataframe, for the xtrain dataframe and finally activity for the ytrain dataframe.

At this point we bind the 3 dataframes subject, ytrain, and xtrain by column to create a temporary dataframe train, the train dataframe is the full data for all the subjects in the training subject group. We remove the row, subject, xtrain, ytrain, dataframes/variables as they are no longer needed.

The above process is then repeated to create a test dataframe with all the subjects in the testing group. Again we remove the dataframes/variables that are no longer needed.

Finally the train and test dataframes are bound by row to create a combined dataframe fulldata, of the testing and training groups. As the test and train dataframes are no longer needed they are removed. As a convenience and to alleviate re-processing, the fulldata frame is at this point written out to a file "data.txt" in the working directory. Should it be desired or necessary to re-run this script the data.txt file will read in hopefully saving some extra processing.

From the fulldata we extract 66 columns for the mean and standard deviation values, storing them into a datatable. Column/variable names are converted to a more tidy format, ordered, averages calculated, and written out to a text data file called tidydataset.txt in the working directory using write.table.

To read the tidydataset.txt into R and view it, the following commands may be used:

tidydata <- read.table("tidydataset.txt", header = T)

View(tidydata)

g-cd_project's People

Contributors

trax- avatar

Watchers

James Cloos 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.