Git Product home page Git Product logo

getdata's Introduction

README

The script for the course project is called run_analysis.R. Usage:

  • Download and unzip the course project's data from https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip
  • Start R with the working directory being the directory of the unzipped data, i.e. 'UCI HAR Dataset'.
  • Source the run_analysis.R script. Assuming it is in the directory above, exectute source("../run_analysis.R")
  • This will produce the required output file as "averages.txt" in the current working directory.

How the script works

run_analysis.R first reads all relevant files with read.table. We read the actual data, but also the features.txt and activity_labels.txt. features.txt is used to read the column names; these names are used to select only the mean and standard deviation columns, and to set the column names. activity_labels.txt is used to translate the activities from integer (range 1:6) into a text.

We "grep" the appropriate column numbers and names, then extract these columns from x_test and x_train.

Then (line 24-26) the test and training data are joined. Line 29 sets all column names from the features.txt file names. Line 31,32 clean these names up a bit.

Line 35 translates the activity integers into the respective texts.

Before calculating the averages, lines 38-40 verify that all data is present and no data are missing (na).

Then we produce the average using the aggregate function, computing the mean by activity and subject. In the result (r), we set the first column names to descriptive names.

Line 48 then writes the output file, using write.table as prescribed.

getdata's People

Contributors

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