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:

  1. Merges the training and the test sets to create one data set.
  2. Extracts only the measurements on the mean and standard deviation for each measurement.]
  3. Uses descriptive activity names to name the activities in the data set
  4. Appropriately labels the data set with descriptive variable names.
  5. 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.
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

INSIDE run_analysis.R

STEP 1 Reading and Merging

 * 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 **

STEP 2 & 3 Extracts only the measurements on the mean and standard deviation for each measurement.AND Uses descriptive activity names to name the activities in the data set

       R-Script called ** extractMeanStd.R **

STEP 4 Appropriately labels the data set with descriptive variable names.

       R-Script called ** cleanLabel.R **

STEP 5A 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.

Output is stored in data frame : ** final.df *

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

STEP 5B Writing final data to txt file

data frame "final.df" is written into text file named "analysedData.txt"


datascience122015/runAnalysis documentation built on May 14, 2019, 7:46 p.m.