This repository consists of three files:
- tidy_data.txt
- run_analysis.R
- CodeBook.md
The file 'tidy_data.txt' contains the tidy data set obtained by applying code in 'run_analysis.R' to the original data from the accelerometers and gyroscope from the Samsung Galaxy S smartphone. Each row corresponds to a subject and activity. The variables for columns are explained in CodeBook.md.
The file 'tidy_data.txt' can be read with the command 'read.table("tidy_data.txt")'.
In the file 'run_analysis.R' we perform the following steps:
- use 'read.table' command to read the training and test set
- use 'rbind' to merge them to one data set 'data'
- read the variable names for columns in the 'features' data frame
- check which features contain 'mean()' or 'std()'
- keep only these columns of 'data' that contain 'mean()' or 'std()'
- read activities for each row of the training and test set
- use 'rbind' to combine them into one data frame 'activities'
- use 'activity_labels.txt' to replace the activity numbers by names ('activitiesByNames')
- replace the variables by descriptive variable names
- read subjects for each row of the training and test set
- use 'rbind' to combine them into one data frame 'subjects'
- group data by subjects and activities
- use 'summarise_each' to summarise the grouped data by average values for each column