run_analysis.R contains all the functions necessary to complete the peer assignment. Clone this Github repository and add the zipped data file from the Coursera website. Unzipping the file generates directory called UCI HAR Dataset. Use setwd() in R or R-Studio to navigate to the directory generated by git clone.
Functions in run_analysis.R:
merge_datasets(data_set1 = "UCI HAR Dataset/train/X_train.txt",
data_set2 = "UCI HAR Dataset/test/X_test.txt")
merge_datasets() is the first step to merge both data sets. Defaults assume that the current path contains the directory UCI HAR Dataset and the data sets are named X_train.txt and X_test.txt
reduce_dataset(data_frame,
features = "UCI HAR Dataset/features.txt")
reduce_dataset() leaves as per assignment only columns that contain means and standard deviation. Names of the columns are assigned as per features.txt
simpleCap(string, split = "_")
simpleCap() is adapted from ETH R lanuage website. Makes sure only 1st letter in word is capitalized
create_cleanset(data_set1 = "UCI HAR Dataset/train/X_train.txt",
data_set2 = "UCI HAR Dataset/test/X_test.txt",
subject_set1 = "UCI HAR Dataset/train/subject_train.txt",
subject_set2 = "UCI HAR Dataset/test/subject_test.txt",
activity_set1 = "UCI HAR Dataset/train/y_train.txt",
activity_set2 = "UCI HAR Dataset/test/y_test.txt",
labels = "UCI HAR Dataset/activity_labels.txt",
features = "UCI HAR Dataset/features.txt")
create_cleanset() generates automatically the required tidy dataset.