It is now possible to collect a large amount of data about personal movement using activity monitoring devices such as a Fitbit, Nike Fuelband, or Jawbone Up. These type of devices are part of the “quantified self” movement – a group of enthusiasts who take measurements about themselves regularly to improve their health, to find patterns in their behavior, or because they are tech geeks. But these data remain under-utilized both because the raw data are hard to obtain and there is a lack of statistical methods and software for processing and interpreting the data.
This assignment makes use of data from a personal activity monitoring device. This device collects data at 5 minute intervals through out the day. The data consists of two months of data from an anonymous individual collected during the months of October and November, 2012 and include the number of steps taken in 5 minute intervals each day.
Data Source: https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2Factivity.zip
Make a histogram depicting the total number of steps taken each day
Calculate and report the mean and median of the total number of steps taken per day
The mean of the total number of steps per day is 10766, and the median of the total number of steps is 10765.
Make a time series plot (i.e. type=“l”) of the 5-minute interval (x-axis) and the average number of steps taken, averaged across all days (y-axis).
Which 5-minute interval, on average across all the days in the dataset, contains the maximum number of steps?
The 5-minute interval, on average across all the days in the dataset is 835, and contains the maximum number of 206 steps.
Note that there are a number of days/intervals where there are missing values (coded as NA). The presence of missing days may introduce bias into some calculations or summaries of the data.
Calculate and report the total number of missing values in the dataset (i.e. the total number of rows with NAs).
The total number of rows with missing values in the PA1 dataset is 2304.
Devise a strategy for filling in all of the missing values in the dataset. The strategy does not need to be sophisticated. For example, you could use the mean/median for that day, or the mean for that 5-minute interval, etc.
My approach will be to fill in the NA values with the table mean of the 5 minute interval.
Create a new dataset that is equal to the original dataset but with the missing data filled in.
## steps date interval
## 1 0 2012-10-01 0
## 2 0 2012-10-01 5
## 3 0 2012-10-01 10
## 4 0 2012-10-01 15
## 5 0 2012-10-01 20
## 6 0 2012-10-01 25
Make a histogram of the total number of steps taken each day and Calculate and report the mean and median total number of steps taken per day. Do these values differ from the estimates from the first part of the assignment? What is the impact of imputing missing data on the estimates of the total daily number of steps?
Calculate and report the mean and median of the total number of steps taken per day with NAs replaced.
The new mean of the total number of steps per day is 9354, as compared to the original mean of 10766. The new median of the total number of steps is 10395, as compared to the original median of 10765. The mean difference in steps is 1412 and the median difference in steps is 370.
We observe a notable impact in the freqency of the 0 - 500 scale in this histogram, with no change in the distribution from the 500 to 25,000 range. Or a 13% change in mean and 3% change in median.
For this part the function may be of some help here. Use the dataset with the filled-in missing values for this part.
Create a new factor variable in the dataset with two levels – “weekday” and “weekend” indicating whether a given date is a weekday or weekend day.
## steps date interval weekday daytype
## 1 0 2012-10-01 0 Monday Weekday
## 2 0 2012-10-01 5 Monday Weekday
## 3 0 2012-10-01 10 Monday Weekday
## 4 0 2012-10-01 15 Monday Weekday
## 5 0 2012-10-01 20 Monday Weekday
## 6 0 2012-10-01 25 Monday Weekday
Make a panel plot containing a time series plot (i.e. type = “l” ) of the 5-minute interval (x-axis) and the average number of steps taken, averaged across all weekday days or weekend days (y-axis).