This repository contains the submission for the Getting and Cleaning Data Course Project peer-graded assignment.
run_analysis.R
is a R script with the following functionality.
- Download and unzips the data archive if the data directory
UCI HAR Dataset
is not found - Read the files
subject_train.txt
,subject_test.txt
,X_train.txt
,X_test.txt
,y_train.txt
,y_test.txt
usingread.table
- Merging all data sets into a variable called
activity
and clearing unused variables - Applying the column names
subject
andlabel
to first and second column and reading the remaining column names from the file 'features.txt' - Subsetting the data set to only include column that have
mean()
,std()
,subject
orlabel
in their names usinggrepl
- Using the
factor
function to replace the 'label' observations with the activity names from the file fromactivity_labels.txt
- Remove the brackets form the variable names, and lowercase all
label
observations - Requiring the
dplyr
package, the script uses thegroup_by
andsummarize_at
functions to generate a new tidy data set with the average of each variable for each activity and each subject - Writing out the resulting tidy data set into a file called
activity_mean.csv
and the data set features into a file namedactivity_mean-features.txt
The codebook for the resulting tidy data set in provided in a file named activity_mean-codebook.txt
, in the same format and style as the codebook features_info.txt
from the original data UCI HAR Dataset set.