Giter Club home page Giter Club logo

data-cleaning's Introduction

Data Cleaning Project

Intro

This script is for processing the UCI HAR dataset that tracks people's movements using their cellphones. The original dataset is broken into several different files, which have been combined using this script. This readme will give an overview of the processes of the script, and you can refer to the included code book for more details. The script assumes that you already have the dataset root directory as your working directory.

Loading and Arranging Data

For this assignment, only the features that include the means and standard deviations are required, so first the features file is read into a table. Using regex, the indicies of the features including mean and standard deviation data are extracted, and then used to trim down the training and test datasets to only those components. The subject number and activity number for each entry were read in through their respective files, and added as columns onto the datasets. Before adding the activities in, however, the numbers were replaced by the descriptive names provided in the activity_labels.txt file. Once both the training and test data were transformed in this way, they were combined into one large dataset.

Creating the Tidy Dataset

Now having all of the data in one place, the subject and activity columns were both turned into factor variables so that they could be more easily iterated over to arrive and the mean for each variable broken down by those two categories. An empty data frame was initialized, and then added to row by row using nested for loops to select each subject, and then activity by that subject. The result is a dataset that includes the mean of the means and standard deviations for each subject's activities. From thirty subjects performing six activities, this makes a set with one-hundred eighty observations and eighty-one variables including the labels for subject and activity.

Result

The result is the tidy_data.txt file included in the repo. It was created using the write.table function in R, and can easily be loaded back in using read.table. The first line includes the column names, so header option should be set to true.

data-cleaning's People

Contributors

ztaylorpossible 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.