├── PA1_template.Rmd ├── README.md ├── activity.zip ├── doc └── instructions.pdf └── instructions_fig └── sample_panelplot.png /PA1_template.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Reproducible Research: Peer Assessment 1" 3 | output: 4 | html_document: 5 | keep_md: true 6 | --- 7 | 8 | 9 | ## Loading and preprocessing the data 10 | 11 | 12 | 13 | ## What is mean total number of steps taken per day? 14 | 15 | 16 | 17 | ## What is the average daily activity pattern? 18 | 19 | 20 | 21 | ## Imputing missing values 22 | 23 | 24 | 25 | ## Are there differences in activity patterns between weekdays and weekends? 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | It is now possible to collect a large amount of data about personal 4 | movement using activity monitoring devices such as a 5 | [Fitbit](http://www.fitbit.com), [Nike 6 | Fuelband](http://www.nike.com/us/en_us/c/nikeplus-fuelband), or 7 | [Jawbone Up](https://jawbone.com/up). These type of devices are part of 8 | the "quantified self" movement -- a group of enthusiasts who take 9 | measurements about themselves regularly to improve their health, to 10 | find patterns in their behavior, or because they are tech geeks. But 11 | these data remain under-utilized both because the raw data are hard to 12 | obtain and there is a lack of statistical methods and software for 13 | processing and interpreting the data. 14 | 15 | This assignment makes use of data from a personal activity monitoring 16 | device. This device collects data at 5 minute intervals through out the 17 | day. The data consists of two months of data from an anonymous 18 | individual collected during the months of October and November, 2012 19 | and include the number of steps taken in 5 minute intervals each day. 20 | 21 | ## Data 22 | 23 | The data for this assignment can be downloaded from the course web 24 | site: 25 | 26 | * Dataset: [Activity monitoring data](https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2Factivity.zip) [52K] 27 | 28 | The variables included in this dataset are: 29 | 30 | * **steps**: Number of steps taking in a 5-minute interval (missing 31 | values are coded as `NA`) 32 | 33 | * **date**: The date on which the measurement was taken in YYYY-MM-DD 34 | format 35 | 36 | * **interval**: Identifier for the 5-minute interval in which 37 | measurement was taken 38 | 39 | 40 | 41 | 42 | The dataset is stored in a comma-separated-value (CSV) file and there 43 | are a total of 17,568 observations in this 44 | dataset. 45 | 46 | 47 | ## Assignment 48 | 49 | This assignment will be described in multiple parts. You will need to 50 | write a report that answers the questions detailed below. Ultimately, 51 | you will need to complete the entire assignment in a **single R 52 | markdown** document that can be processed by **knitr** and be 53 | transformed into an HTML file. 54 | 55 | Throughout your report make sure you always include the code that you 56 | used to generate the output you present. When writing code chunks in 57 | the R markdown document, always use `echo = TRUE` so that someone else 58 | will be able to read the code. **This assignment will be evaluated via 59 | peer assessment so it is essential that your peer evaluators be able 60 | to review the code for your analysis**. 61 | 62 | For the plotting aspects of this assignment, feel free to use any 63 | plotting system in R (i.e., base, lattice, ggplot2) 64 | 65 | Fork/clone the [GitHub repository created for this 66 | assignment](http://github.com/rdpeng/RepData_PeerAssessment1). You 67 | will submit this assignment by pushing your completed files into your 68 | forked repository on GitHub. The assignment submission will consist of 69 | the URL to your GitHub repository and the SHA-1 commit ID for your 70 | repository state. 71 | 72 | NOTE: The GitHub repository also contains the dataset for the 73 | assignment so you do not have to download the data separately. 74 | 75 | 76 | 77 | ### Loading and preprocessing the data 78 | 79 | Show any code that is needed to 80 | 81 | 1. Load the data (i.e. `read.csv()`) 82 | 83 | 2. Process/transform the data (if necessary) into a format suitable for your analysis 84 | 85 | 86 | ### What is mean total number of steps taken per day? 87 | 88 | For this part of the assignment, you can ignore the missing values in 89 | the dataset. 90 | 91 | 1. Make a histogram of the total number of steps taken each day 92 | 93 | 2. Calculate and report the **mean** and **median** total number of steps taken per day 94 | 95 | 96 | ### What is the average daily activity pattern? 97 | 98 | 1. 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) 99 | 100 | 2. Which 5-minute interval, on average across all the days in the dataset, contains the maximum number of steps? 101 | 102 | 103 | ### Imputing missing values 104 | 105 | Note that there are a number of days/intervals where there are missing 106 | values (coded as `NA`). The presence of missing days may introduce 107 | bias into some calculations or summaries of the data. 108 | 109 | 1. Calculate and report the total number of missing values in the dataset (i.e. the total number of rows with `NA`s) 110 | 111 | 2. 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. 112 | 113 | 3. Create a new dataset that is equal to the original dataset but with the missing data filled in. 114 | 115 | 4. 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? 116 | 117 | 118 | ### Are there differences in activity patterns between weekdays and weekends? 119 | 120 | For this part the `weekdays()` function may be of some help here. Use 121 | the dataset with the filled-in missing values for this part. 122 | 123 | 1. 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. 124 | 125 | 1. 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). The plot should look something like the following, which was created using **simulated data**: 126 | 127 | ![Sample panel plot](instructions_fig/sample_panelplot.png) 128 | 129 | 130 | **Your plot will look different from the one above** because you will 131 | be using the activity monitor data. Note that the above plot was made 132 | using the lattice system but you can make the same version of the plot 133 | using any plotting system you choose. 134 | 135 | 136 | ## Submitting the Assignment 137 | 138 | To submit the assignment: 139 | 140 | 1. Commit your completed `PA1_template.Rmd` file to the `master` branch of your git repository (you should already be on the `master` branch unless you created new ones) 141 | 142 | 2. Commit your `PA1_template.md` and `PA1_template.html` files produced by processing your R markdown file with the `knit2html()` function in R (from the **knitr** package) 143 | 144 | 3. If your document has figures included (it should) then they should have been placed in the `figure/` directory by default (unless you overrode the default). Add and commit the `figure/` directory to your git repository. 145 | 146 | 4. Push your `master` branch to GitHub. 147 | 148 | 5. Submit the URL to your GitHub repository for this assignment on the course web site. 149 | 150 | In addition to submitting the URL for your GitHub repository, you will 151 | need to submit the 40 character SHA-1 hash (as string of numbers from 152 | 0-9 and letters from a-f) that identifies the repository commit that 153 | contains the version of the files you want to submit. You can do this 154 | in GitHub by doing the following: 155 | 156 | 1. Go into your GitHub repository web page for this assignment 157 | 158 | 2. Click on the "?? commits" link where ?? is the number of commits you have in the repository. For example, if you made a total of 10 commits to this repository, the link should say "10 commits". 159 | 160 | 3. You will see a list of commits that you have made to this repository. The most recent commit is at the very top. If this represents the version of the files you want to submit, then just click the "copy to clipboard" button on the right hand side that should appear when you hover over the SHA-1 hash. Paste this SHA-1 hash into the course web site when you submit your assignment. If you don't want to use the most recent commit, then go down and find the commit you want and copy the SHA-1 hash. 161 | 162 | A valid submission will look something like (this is just an **example**!) 163 | 164 | ```r 165 | https://github.com/rdpeng/RepData_PeerAssessment1 166 | 167 | 7c376cc5447f11537f8740af8e07d6facc3d9645 168 | ``` 169 | -------------------------------------------------------------------------------- /activity.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdpeng/RepData_PeerAssessment1/80edf39c3bb508fee88e3394542f967dd3fd3270/activity.zip -------------------------------------------------------------------------------- /doc/instructions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdpeng/RepData_PeerAssessment1/80edf39c3bb508fee88e3394542f967dd3fd3270/doc/instructions.pdf -------------------------------------------------------------------------------- /instructions_fig/sample_panelplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdpeng/RepData_PeerAssessment1/80edf39c3bb508fee88e3394542f967dd3fd3270/instructions_fig/sample_panelplot.png --------------------------------------------------------------------------------