forked from rdpeng/RepData_PeerAssessment1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PA1_template.txt
81 lines (49 loc) · 1.4 KB
/
PA1_template.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Reproducible Research: Peer Assessment 1
## Loading and preprocessing the data
```r
library(dplyr)
```
```
##
## Attaching package: 'dplyr'
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
```
```r
library(xtable)
data <- read.csv("activity.csv")
```
## What is mean total number of steps taken per day?
```r
stepsPerDay <- data %>%
group_by(date) %>%
summarize(tot = sum(steps, na.rm = T))
hist(stepsPerDay$tot, main = "Histogram of Steps per Day", xlab = "Steps per Day")
```
![](PA1_template_files/figure-html/unnamed-chunk-2-1.png)
```r
dtMean <- round(mean(stepsPerDay$tot),digits = 2)
dtMedian <- median(stepsPerDay$tot)
```
#### Mean: 9354.23
#### Median: 10395
## What is the average daily activity pattern?
```r
stepsPerTime <- data %>%
group_by(interval) %>%
summarize(avg = mean(steps, na.rm=T))
plot(stepsPerTime$interval,stepsPerTime$avg,type = "l",main="Avg Steps per Interval",xlab="5 min interval",ylab="Avg Steps")
```
![](PA1_template_files/figure-html/unnamed-chunk-3-1.png)
```r
dtMax <- filter(stepsPerTime, avg == max(stepsPerTime$avg)) %>% select(interval)
```
#### Interval with highest average steps: 835
## Imputing missing values
## Are there differences in activity patterns between weekdays and weekends?