Skip to content

Commit

Permalink
Individual slides
Browse files Browse the repository at this point in the history
  • Loading branch information
rdpeng committed Dec 31, 2014
1 parent e28bce9 commit c6944be
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 36 deletions.
13 changes: 6 additions & 7 deletions 03_GettingData/dplyr/dplyr.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
% Managing Data Frames with `dplyr`
% Biostatistics 140.776
%

```{r, echo=FALSE, results="hide"}
Expand Down Expand Up @@ -177,12 +176,12 @@ Generating summary statistics by stratum

```{r, tidy=FALSE}
chicago <- mutate(chicago,
tempcat = factor(1 * (tmpd > 90),
tempcat = factor(1 * (tmpd > 80),
labels = c("cold", "hot")))
hotcold <- group_by(chicago, tempcat)
summarize(hotcold, pm25 = mean(pm25, na.rm = TRUE),
o3 = max(o3tmean2, na.rm = TRUE),
no2 = median(no2tmean2, na.rm = TRUE))
o3 = max(o3tmean2),
no2 = median(no2tmean2))
```


Expand All @@ -207,15 +206,15 @@ chicago$year <- NULL ## Can't use mutate to create an existing variable
# `%>%`

```{r,tidy=FALSE,eval=FALSE}
chicago %>% mutate(year = as.POSIXlt(date)$year + 1900)
%>% group_by(year)
chicago %>% mutate(month = as.POSIXlt(date)$mon + 1)
%>% group_by(month)
%>% summarize(pm25 = mean(pm25, na.rm = TRUE),
o3 = max(o3tmean2, na.rm = TRUE),
no2 = median(no2tmean2, na.rm = TRUE))
```

```{r,echo=FALSE}
chicago %>% mutate(year = as.POSIXlt(date)$year + 1900) %>% group_by(year) %>%
chicago %>% mutate(month = as.POSIXlt(date)$mon + 1) %>% group_by(month) %>%
summarize(pm25 = mean(pm25, na.rm = TRUE), o3 = max(o3tmean2, na.rm = TRUE), no2 = median(no2tmean2, na.rm = TRUE))
```
Expand Down
50 changes: 21 additions & 29 deletions 03_GettingData/dplyr/dplyr.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
% Managing Data Frames with `dplyr`
% Biostatistics 140.776
%


Expand Down Expand Up @@ -323,20 +322,20 @@ Generating summary statistics by stratum

```r
chicago <- mutate(chicago,
tempcat = factor(1 * (tmpd > 90),
tempcat = factor(1 * (tmpd > 80),
labels = c("cold", "hot")))
hotcold <- group_by(chicago, tempcat)
summarize(hotcold, pm25 = mean(pm25, na.rm = TRUE),
o3 = max(o3tmean2, na.rm = TRUE),
no2 = median(no2tmean2, na.rm = TRUE))
o3 = max(o3tmean2),
no2 = median(no2tmean2))
```

```
## Source: local data frame [3 x 4]
##
## tempcat pm25 o3 no2
## 1 cold 16.21831 66.587500 24.55492
## 2 hot NaN 58.549524 26.04565
## 1 cold 15.97807 66.587500 24.54924
## 2 hot 26.48118 62.969656 24.93870
## 3 NA 47.73750 9.416667 37.44444
```

Expand Down Expand Up @@ -387,37 +386,30 @@ summarize(years, pm25 = mean(pm25, na.rm = TRUE),


```r
chicago %>% mutate(year = as.POSIXlt(date)$year + 1900)
%>% group_by(year)
chicago %>% mutate(month = as.POSIXlt(date)$mon + 1)
%>% group_by(month)
%>% summarize(pm25 = mean(pm25, na.rm = TRUE),
o3 = max(o3tmean2, na.rm = TRUE),
no2 = median(no2tmean2, na.rm = TRUE))
```


```
## Source: local data frame [19 x 4]
## Source: local data frame [12 x 4]
##
## year pm25 o3 no2
## 1 1987 NaN 62.96966 23.49369
## 2 1988 NaN 61.67708 24.52296
## 3 1989 NaN 59.72727 26.14062
## 4 1990 NaN 52.22917 22.59583
## 5 1991 NaN 63.10417 21.38194
## 6 1992 NaN 50.82870 24.78921
## 7 1993 NaN 44.30093 25.76993
## 8 1994 NaN 52.17844 28.47500
## 9 1995 NaN 66.58750 27.26042
## 10 1996 NaN 58.39583 26.38715
## 11 1997 NaN 56.54167 25.48143
## 12 1998 18.26467 50.66250 24.58649
## 13 1999 18.49646 57.48864 24.66667
## 14 2000 16.93806 55.76103 23.46082
## 15 2001 16.92632 51.81984 25.06522
## 16 2002 15.27335 54.88043 22.73750
## 17 2003 15.23183 56.16608 24.62500
## 18 2004 14.62864 44.48240 23.39130
## 19 2005 16.18556 58.84126 22.62387
## month pm25 o3 no2
## 1 1 17.76996 28.22222 25.35417
## 2 2 20.37513 37.37500 26.78034
## 3 3 17.40818 39.05000 26.76984
## 4 4 13.85879 47.94907 25.03125
## 5 5 14.07420 52.75000 24.22222
## 6 6 15.86461 66.58750 25.01140
## 7 7 16.57087 59.54167 22.38442
## 8 8 16.93380 53.96701 22.98333
## 9 9 15.91279 57.48864 24.47917
## 10 10 14.23557 47.09275 24.15217
## 11 11 15.15794 29.45833 23.56537
## 12 12 17.52221 27.70833 24.45773
```


Expand Down
Binary file modified 03_GettingData/dplyr/dplyr.pdf
Binary file not shown.
Binary file added 03_GettingData/dplyr/slides/dplyr01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 03_GettingData/dplyr/slides/dplyr19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c6944be

Please sign in to comment.