The run_analysis.R performs the following procedures:
-
Verifies existence of the Data folder. If such folder does not exist, R will download it. The URL of the data is the following link: https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip
-
The data files (X,Y files of the train and test data sets) are loaded as CSV files.
-
Data frames are merged by using
rbindandcbindcombining Subject, Activity and Measurements observations. -
Columns' names are given by extracting them from features.txt file, which is included in the data set.
-
Columns that contain mean or std are found by using
grepl. -
IDs and names of activities are read from the activity_labels.txt file. The factor function is used to convert the activity IDs into descriptive names.
-
Using
ddplya second data set is created. This data set includes the average of each variable given each activity and subject. -
Finally,
write.csvis used to create the tidy data set in the same folder asrun_analysis.Rscript.