The cleanup script (run_analysis.R) 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 activity names.
- Creates a second, independent tidy data set with the average of each variable for each activity and each subject.
Requires reshape2
To run the script, source run_analysis.R
. After running, you will see the following output as the script works:
Reading data sets
STR - checking the variables for numeric
Change X_test and X_train to numeric data frames from character
Add the feature labels to X_test
Change Y_test labels to include human readable Activity
bind X_teat and Y_test now properly labeled
repeat the process for respective train txt files
combine XY_test and XY_ train to form completed tidy data set
completed tidy data set has activity labels added
ONLY mean and std metrics extracted
New data.frame created based on these extracted metrics
Creates a second independent tidy data set with the average of each variable for each activity and each subject
- Read in text files
- Convert character data to numeric in X-Test and X_train
- label X-Test with the 561 Features
- Label Y Test V1 as Activity
- using cBind combine X_test and Y_test
- Add subject
- Repeat steps 3 to 6 for Train data
- bind the two XY_Train & XY_Test together creating complete data set
- NOTE 3rd request of project here Uses descriptive activity names to name the activities in the data set
- The second request of project Extracts only the measurements on the mean and standard deviation for each measurement
- Using the extracted elements create a data set that has only the mean & std variables
- Creates a second independent tidy data set with the average of each variable for each activity and each subject from the set with just mean and std
- Write the clean dataset to disk
The resulting clean dataset is exported to working directory as Second_Tidy_Averages.csv
Data set information was download from http://archive.ics.uci.edu/ml/datasets/Human+Activity+Recognition+Using+Smartphones#. "The experiments have been carried out with a group of 30 volunteers within an age bracket of 19-48 years. Each person performed six activities (WALKING, WALKING UPSTAIRS, WALKING DOWNSTAIRS, SITTING, STANDING, LAYING) wearing a smartphone (Samsung Galaxy S II) on the waist. Using its embedded accelerometer and gyroscope, we captured 3-axial linear acceleration and 3-axial angular velocity at a constant rate of 50Hz. The experiments have been video-recorded to label the data manually. The obtained dataset has been randomly partitioned into two sets, where 70% of the volunteers was selected for generating the training data and 30% the test data. The sensor signals (accelerometer and gyroscope) were pre-processed by applying noise filters and then sampled in fixed-width sliding windows of 2.56 sec and 50% overlap (128 readings/window). The sensor acceleration signal, which has gravitational and body motion components, was separated using a Butterworth low-pass filter into body acceleration and gravity. The gravitational force is assumed to have only low frequency components, therefore a filter with 0.3 Hz cutoff frequency was used. From each window, a vector of features was obtained by calculating variables from the time and frequency domain.”