In this project, you could find a R script run_analysis.R
, it contains the function to implement the data analysis process which required by the coursera lecture Getting and Cleaning Data
. Before you assess the program, please read this file first.
-
Please download the data of this project from[https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip(https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip)], and unzip it.
-
Please move the folder which contains the required data to the root of this project. You should have the structure like this:
- Getting-CleaningData-->UCI HAR Dataset-->test
- -------------------------------------------------------->train
- -------------------------------------------------------->...
Or, please specify the path of the folder by using
path
paramenter. -
Run the script
run_analysis.R
and you will get the output (by default, it isoutput.txt
, you can also specify it by usingfile.name
parameter) in the root of this project. -
If you want to observer the process of this script, please specify parameter
debug
asTRUE
, then you will get some details when you runing it.
- The data are extracted which only contain
mean
orstd
in their column name. - The row of the output file indicating 30 different subjects, and the column of the output file indicating activity label and measurements.
The output file is created by the following processes:
- Read x, y and subject both in train and test folder.
- Merge train and test data.
- Label the column of x according to
features.txt
. - Extract colmns of x according to the key words
mean
andstd
. - Label the column of y, and replace its value with descriptive names.
- Label the column of subject.
- Merge x, y and subject into one called
data
. - Split
data
according toactivity_labels
. - Aggregate data according to
subject
in each activity. - Output result.