This is the course project for the Getting and Cleaning Data Coursera course.
The R script, run_analysis.R
, does the following:
- Sets path
- Loads the activity and feature info
- Loads both the training and test datasets, keeping only those columns which reflect a mean or standard deviation
- Loads the activity and subject data for each dataset, and merges those columns with the dataset
- Merges the two datasets
- Converts the
activity
andsubject
columns into factors - Creates a tidy dataset that consists of the average (mean) value of each variable of interest for each subject and activity pair.
The end result is shown in the file alldataSet.txt
.
##How to run
- Open the R script run_analysis.R using RStudio
- Set the working path depending on your directories structure call to the working directory/folder (i.e., the folder where these the R script file is saved).
- Run the R script run_analysis.R
- it Merges the training and the test sets to create one data set.
- Extracts only the measurements on the mean and standard deviation for each measurement.
- Uses descriptive activity names to name the activities in the data set
- Appropriately labels the data set with descriptive activity names.
- Creates a second, independent tidy data set with the average of each variable of interest for each activity and each subject. it's called allDataSet.txt
##data set description The dataset includes the following files:
'README.txt'
'features_info.txt': Shows information about the variables used on the feature vector.
'features.txt': List of all features.
'activity_labels.txt': Links the class labels with their activity name.
'train/X_train.txt': Training set.
'train/y_train.txt': Training labels.
'test/X_test.txt': Test set.
'test/y_test.txt': Test labels.
The following files are available for the train and test data. Their descriptions are equivalent.
'train/subject_train.txt': Each row identifies the subject who performed the activity for each window sample. Its range is from 1 to 30.
'train/Inertial Signals/total_acc_x_train.txt': The acceleration signal from the smartphone accelerometer X axis in standard gravity units 'g'. Every row shows a 128 element vector. The same description applies for the 'total_acc_x_train.txt' and 'total_acc_z_train.txt' files for the Y and Z axis.
'train/Inertial Signals/body_acc_x_train.txt': The body acceleration signal obtained by subtracting the gravity from the total acceleration.
'train/Inertial Signals/body_gyro_x_train.txt': The angular velocity vector measured by the gyroscope for each window sample. The units are radians/second.
- subject
- activity
- featDomain
- featAcceleration
- featInstrument
- featJerk
- featMagnitud
- efeatVariable
- featAxis
- count
- average