The provided script manipulates and cleans up the dataset "Human Activity Recognition Using Smartphones" provided by the UCI Machine Learning Repository. This dataset contains the results of an experiment which involved 30 subjects ranging from 18-48 years of age. The subjects had a smartphone with an accelerometer and gyroscope attached to their waists and were observed as they completed a number of tasks, recording 3-axial angular velocity measurements. These raw measurements were then further manipulated before being compiled in the dataset.
More information about this dataset is available under the following address:
http://archive.ics.uci.edu/ml/datasets/Human+Activity+Recognition+Using+Smartphones
The script run_analysis.R
checks to see if the zipped dataset file already exists in the user's working directory and otherwise downloads the dataset provided by the UCI Machine Learning Repository.
The downloaded .ZIP archive is then unzipped (if the unzipped directory is not already detected) and the provided training and test sets are merged in order to create one data set, extracting only the measurements of mean and standard deviation for each measurement. The activities in this dataset are named descriptively based on tidy verisions of the original labels provided in the dataset (for a detailed description of each activity, see the corresponding entry in CODEBOOK.md
). Additionally, all of the variables in this dataset are provided a descriptive name (see a detailed description in CODEBOOK.md
).
Finally, this script produces a tidy dataset containing only the average of each variable for each activity and each subject, which is contained in the file tidy.txt
. The script displays the tidy dataset upon completion.
In order to view the resulting tidy dataset generated by this script, run the following code in your R console:
url <- "https://raw.githubusercontent.com/kcole93/gettingandcleaningdata/master/tidy.txt"
url <- sub("^https", "http", url)
data <- read.table(url(url), header = TRUE)
View(data)