##Introduction
This repository contains the files and program I created for the Coursera course "Getting and Cleaning Data" (offered in September of 2015) through Johns Hopkins University as part of the Data Science Specialization Track.
##About The assignment Text detailing the assignment:
The purpose of this project is to demonstrate your ability to collect, work with, and clean a data set. The goal is to prepare tidy data that can be used for later analysis. You will be graded by your peers on a series of yes/no questions related to the project. You will be required to submit:
- a tidy data set as described below,
- a link to a Github repository with your script for performing the analysis, and
- a code book that describes the variables, the data, and any transformations or work that you performed to clean up the data called CodeBook.md.
One of the most exciting areas in all of data science right now is wearable computing. Companies like Fitbit, Nike, and Jawbone Up are racing to develop the most advanced algorithms to attract new users. The data linked to from the course website represent data collected from the accelerometers from the Samsung Galaxy S smartphone.
A full description is available at the site where the data was obtained: http://archive.ics.uci.edu/ml/datasets/Human+Activity+Recognition+Using+Smartphones
Here are the data for the project: https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip
You should create one R script called run_analysis.R that does the following.
- Merges the training and the test sets to create one data set.
- Extracts only the measurements on the mean and standard deviation for each measurement.
- Uses descriptive activity names to name the activities in the data set.
- Appropriately labels the data set with descriptive variable names.
- From the data set in step 4, creates a second, independent tidy data set with the average of each variable for each activity and each subject.
The observation data collected are arranged into four data files: Of the total population collected, 70% of the data are partitioned into the "training" data sets and 30% of the data are partitioned into the "test" data sets. For each of the training and test data sets there are additional data files providing the activity codes performed for each observation and the subject performing them. Listed below are the observation data related files:
- X_train.txt - 70% of the data observations
- y_train.txt - activity codes for each training observation
- subject_train.txt - subject performing each activity of the training observations
- X_test.txt - 30% of the data observations
- y_test.txt - activity codes for each test observation
- subject_test.txt - subject performing each activity of the test observations
Additionally, there are data files provided for the activity names and the feature labels. These files cover both the training and the test data sets.
- activity_labels.txt - decodes for the activity codes provided in the data sets above
- features.txt - column names for the datat sets provided above
More information about the raw data can be found in the README.txt and features_info.txt provided with the raw data set.
##About The Approach & Tidy Dataset I like to have my program scripts set everything I need and isolate the working files into clean directories automatically. In addition, I like to compile large data sets and then extract what I need/want from that larger compiled dataset as needed. This approach allows me to easily add columns or rows as desired without having to repeat steps needed to go back to the beginning and compile the desired columns or rows.
Following this philosophy, the below steps outline the approach taken in the program analysis_R written as my submission. Additionally, I have more detailed steps commented out in the program itself.
- Download and prepare workspace and data for assignment
- Load necessary packages in order needed, in this assignment I only used dplyr package
- Read in the source file, unzip files into clean subdirectory within the working directory, & set the new working directory
- Organize each file data into program variables for script reference & clean up features text
- Relabel the columns on datasets using the features text, "activity", and "subject"
- Execute the assignment steps
- Merge the training and the test sets to create one data set with labels and headers.
- Extract only the measurements on the mean and standard deviation for each measurement.
- Use descriptive activity names to name the activities in the data set
- Appropriately label the data set with descriptive variable names (done in preparation steps above)
- From the data set in step 4, create a second, independent tidy data set with the average of each variable for each activity and each subject.
- Show tidy data table