This document describes the code inside run_analysis.R.
The code is divided into section by comments as per the required steps for the assignment:
INPUT DATA : =========== Zip file downloaded from (data set) : https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip
OUTPUT FILE: analysedData.txt Requirement for the final analysed data: ======================================== Average/mean in standard units of each variable for each activity and each subject.
STEPS for EXECUTION ==================== Copy R-scripts in a folder. Set the working-directory to the folder. Run the R-Script - run_analysis.R
* READING DATA * - READ SUBJECT IDS - READ ACTIVITY IDS - READ activity master - READING features.txt has the column headers - READ DATA -TEST - READ DATA -TRAIN R-Script called ** loadFiles.R ** * DATA CLEANING, RESHAPING AND MERGING * - ADDING ACTIVITY DESCRIPTION - CREATING SUBJECT-ACTIVITY WITH ACTIVITY DESCRIPTION INSTEAD OF CODE - ASSIGNING FEATURE ROWS AS COLUMN HEADER TO BOTH TEST AND TRAIN DATA - ADDING SUBJECT & ACTIVITY DESCRIPTION TO BOTH TEST AND TRAIN DATA - MERGING DATA R-Script called ** reshapeCleanMerge.R **
R-Script called ** extractMeanStd.R **
R-Script called ** cleanLabel.R **
R-Script called ** calculateMean.R **
final.df data frames with indicative values after ** calculateMean.R ** execution: ================================================================================= > str(final.df) 'data.frame': 180 obs. of 68 variables: $ ACTDESC : chr "LAYING" "LAYING" "LAYING" "LAYING" ... $ SUBJID : int 1 10 11 12 13 14 15 16 17 18 ... $ timeBodyAccelerometerMeanXaxis : num 0.222 0.28 0.281 0.26 0.277 ... $ timeBodyAccelerometerMeanYaxis : num -0.0405 -0.0243 -0.0177 -0.0175 -0.0204 ... $ timeBodyAccelerometerMeanZaxis : num -0.113 -0.117 -0.109 -0.108 -0.104 ... $ timeGravityAccelerometerMeanXaxis : num -0.249 -0.453 -0.135 -0.379 -0.157 ... $ timeGravityAccelerometerMeanYaxis : num 0.706 -0.139 0.943 0.803 0.656 ... $ timeGravityAccelerometerMeanZaxis : num 0.4458 -0.0311 0.1126 0.275 0.5989 ... $ timeBodyAccelerometerJerkMeanXaxis : num 0.0811 0.0738 0.0767 0.0854 0.0768 ... $ timeBodyAccelerometerJerkMeanYaxis : num 0.00384 0.0157 0.01222 0.00774 0.01834 ...
data frame "final.df" is written into text file named "analysedData.txt"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.