Skip to content

Commit

Permalink
Fixed broken links to script files
Browse files Browse the repository at this point in the history
  • Loading branch information
ismayc committed Jan 22, 2017
1 parent 724c75d commit f6b757f
Show file tree
Hide file tree
Showing 13 changed files with 1,144 additions and 12 deletions.
4 changes: 2 additions & 2 deletions 04-viz.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,10 @@ In addition, we've created a mind map to help you remember which types of plots
### Script of R code

```{r include=FALSE, eval=FALSE}
knitr::purl("04-viz.Rmd", "docs/04-viz.R")
knitr::purl("04-viz.Rmd", "docs/scripts/04-viz.R")
```

An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/04-viz.R).
An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/scripts/04-viz.R).


### What's to come?
Expand Down
4 changes: 2 additions & 2 deletions 05-manip.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,10 @@ We will focus only on the `dplyr` functions in this book, but you are encouraged
### Script of R code

```{r include=FALSE, eval=FALSE}
knitr::purl("05-manip.Rmd", "docs/05-manip.R")
knitr::purl("05-manip.Rmd", "docs/scripts/05-manip.R")
```

An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/05-manip.R).
An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/scripts/05-manip.R).



Expand Down
4 changes: 2 additions & 2 deletions 06-sim.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ In this chapter, we've discussed three functions in the `mosaic` package useful
### Script of R code

```{r include=FALSE, eval=FALSE}
knitr::purl("06-sim.Rmd", "docs/06-sim.R")
knitr::purl("06-sim.Rmd", "docs/scripts/06-sim.R")
```

An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/06-sim.R).
An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/scripts/06-sim.R).


### What's to come?
Expand Down
4 changes: 2 additions & 2 deletions 07-hypo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,10 @@ Since all three conditions are met, we can be reasonably certain that the theory
### Script of R code

```{r include=FALSE, eval=FALSE}
knitr::purl("07-hypo.Rmd", "docs/07-hypo.R")
knitr::purl("07-hypo.Rmd", "docs/scripts/07-hypo.R")
```

An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/07-hypo.R).
An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/scripts/07-hypo.R).


### What's to come?
Expand Down
4 changes: 2 additions & 2 deletions 08-ci.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ Describe how $s / \sqrt{n}$ does in approximating the standard error for these t
### Script of R code

```{r include=FALSE, eval=FALSE}
knitr::purl("08-ci.Rmd", "docs/08-ci.R")
knitr::purl("08-ci.Rmd", "docs/scripts/08-ci.R")
```

An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/08-ci.R).
An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/scripts/08-ci.R).

### What's to come?

Expand Down
4 changes: 2 additions & 2 deletions 09-regress.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ We have reason to doubt whether a linear regression is valid here. Unfortunatel
### Script of R code

```{r include=FALSE, eval=FALSE}
knitr::purl("09-regress.Rmd", "docs/09-regress.R")
knitr::purl("09-regress.Rmd", "docs/scripts/09-regress.R")
```

An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/09-regress.R).
An R script file of all R code used in this chapter is available [here](http://ismayc.github.io/moderndiver-book/scripts/09-regress.R).


### What's to come?
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Converted last updated in index.Rmd to inline instead of R chunk
* Fixed edit link to point to moderndive-book GitHub repo instead of moderndive-source repo
* Fixed broken links to script files at the end of Chapters 4-9
* Attempting to fix Shiny app in Figure 6.2 appearing as white box in published site noted [here](https://github.com/ismayc/moderndiver-book/issues/2)

# ModernDive 0.1.1
Expand Down
200 changes: 200 additions & 0 deletions docs/scripts/04-viz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
## ----setup_viz, include=FALSE--------------------------------------------
chap <- 4
lc <- 0
rq <- 0
# **`r paste0("(LC", chap, ".", (lc <- lc + 1), ")")`**
# **`r paste0("(RQ", chap, ".", (rq <- rq + 1), ")")`**
knitr::opts_chunk$set(
tidy = FALSE,
out.width = '\\textwidth',
fig.height = 4,
warning = FALSE
)

## ----warning=FALSE-------------------------------------------------------
library(ggplot2)
library(nycflights13)
library(knitr)
library(dplyr)

## ----minard, echo=FALSE, fig.cap="Minard's Visualization of Napolean's March"----
knitr::include_graphics("images/Minard.png")

## ---- echo=FALSE---------------------------------------------------------
map <- data_frame(
data = c("longitude", "latitude", "army size", "army direction"),
aes = c("x", "y", "size", "color"),
geom = c("point", "point", "path", "path")
)
line_graph <- data_frame(
data = c("date", "temperature"),
aes = c("x", "y"),
geom = c("line & text", "line & text")
)

knitr::kable(
list(
map,
line_graph
),
caption = "Grammar of Map (Top) and Line-Graph (Bottom) in Minard's Graphic of Napolean's March", booktabs = TRUE
)

## ----viz_review, type='review', engine="block"---------------------------
**_Review questions_**

## ------------------------------------------------------------------------
data(flights)
all_alaska_flights <- flights %>%
filter(carrier == "AS")

## ----lc-all_alaska_flights, type='learncheck', engine="block"------------
**_Learning check_**

## ----noalpha, fig.cap="Arrival Delays vs Departure Delays for Alaska Airlines flights from NYC in 2013"----
ggplot(data = all_alaska_flights, aes(x = dep_delay, y = arr_delay)) +
geom_point()

## ----lc-scatter-plots, type='learncheck', engine="block"-----------------
**_Learning check_**

## ----alpha, fig.cap="Delay scatterplot with alpha=0.2"-------------------
ggplot(data = all_alaska_flights, aes(x = dep_delay, y = arr_delay)) +
geom_point(alpha = 0.2)

## ----jitter, fig.cap="Jittered delay scatterplot"------------------------
ggplot(data = all_alaska_flights, aes(x = dep_delay, y = arr_delay)) +
geom_jitter(width = 30, height = 30)

## ----lc-overplotting, type='learncheck', engine="block"------------------
**_Learning check_**

## ------------------------------------------------------------------------
data(weather)
early_january_weather <- weather %>%
filter(origin == "EWR" & month == 1 & day <= 15)

## ----lc-early_january_weather, type='learncheck', engine="block"---------
**_Learning check_**

## ----hourlytemp, fig.cap="Hourly Temperature in Newark for Jan 1-15 2013"----
ggplot(data = early_january_weather, aes(x = time_hour, y = temp)) +
geom_line()

## ----lc-line-graph, type='learncheck', engine="block"--------------------
**_Learning check_**

## ----echo=FALSE, fig.height=0.8, fig.cap="Strip Plot of Hourly Temperature Recordings from NYC in 2013"----
ggplot(data = weather, mapping = aes(x = temp, y = factor("A"))) +
geom_point() +
theme(axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.text.y = element_blank())
hist_title <- "Histogram of Hourly Temperature Recordings from NYC in 2013"

## ---- warning=TRUE, fig.cap=hist_title-----------------------------------
ggplot(data = weather, mapping = aes(x = temp)) +
geom_histogram()

## ----fig.cap=paste(hist_title, "- 60 Bins")------------------------------
ggplot(data = weather, mapping = aes(x = temp)) +
geom_histogram(bins = 60, color = "white")

## ----fig.cap=paste(hist_title, "- Binwidth = 10"), fig.height=5----------
ggplot(data = weather, mapping = aes(x = temp)) +
geom_histogram(binwidth = 10, color = "white")

## ----lc-histogram, type='learncheck', engine="block"---------------------
**_Learning check_**

## ----facethistogram, fig.cap="Faceted histogram"-------------------------
ggplot(data = weather, aes(x = temp)) +
geom_histogram(binwidth = 5, color = "white") +
facet_wrap(~ month, nrow = 4)

## ----lc-facet, type='learncheck', engine="block"-------------------------
**_Learning check_**

## ----badbox, fig.cap="Invalid boxplot specification", fig.height=3.5-----
ggplot(data = weather, aes(x = month, y = temp)) +
geom_boxplot()

## ----monthtempbox, fig.cap="Month by temp boxplot", fig.height=3.7-------
ggplot(data = weather, mapping = aes(x = factor(month), y = temp)) +
geom_boxplot()

## ----lc-boxplot, type='learncheck', engine="block"-----------------------
**_Learning check_**

## ----flightsbar, fig.cap="Number of flights departing NYC in 2013 by airline", fig.height=2.5----
ggplot(data = flights, mapping = aes(x = carrier)) +
geom_bar()

## ------------------------------------------------------------------------
data(airlines)
kable(airlines)

## ----message=FALSE-------------------------------------------------------
flights_table <- flights %>% dplyr::count(carrier)
knitr::kable(flights_table)

## ----lc-barplot, type='learncheck', engine="block"-----------------------
**_Learning check_**

## ----carrierpie, echo=FALSE, fig.cap="The dreaded pie chart", fig.height=5----
ggplot(flights, aes(x = factor(1), fill = carrier)) +
geom_bar(width = 1) +
coord_polar(theta = "y") +
theme(axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.ticks = element_blank(),
axis.text.y = element_blank(),
axis.text.x = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
guides(fill = guide_legend(keywidth = 0.8, keyheight = 0.8))

## ----echo=FALSE, fig.align='center', fig.cap="The only good pie chart", out.height=if(knitr:::is_latex_output()) '2.5in'----
knitr::include_graphics("images/Pie-I-have-Eaten.jpg")

## ----lc-pie-charts, type='learncheck', engine="block"--------------------
**_Learning check_**

## ----message=FALSE-------------------------------------------------------
flights_namedports <- flights %>%
inner_join(airports, by = c("origin" = "faa"))

## ---- fig.cap="Stacked barplot comparing the number of flights by carrier and airport", fig.height=3.5----
ggplot(data = flights_namedports, mapping = aes(x = carrier, fill = name)) +
geom_bar()

## ----lc-barplot-two-var, type='learncheck', engine="block"---------------
**_Learning check_**

## ---- fig.cap="Side-by-side barplot comparing the number of flights by carrier and airport", fig.height=5----
ggplot(data = flights_namedports, mapping = aes(x = carrier, fill = name)) +
geom_bar(position = "dodge")

## ----lc-barplot-stacked, type='learncheck', engine="block"---------------
**_Learning check_**

## ---- fig.cap="Faceted barplot comparing the number of flights by carrier and airport", fig.height=7.5----
ggplot(data = flights_namedports, mapping = aes(x = carrier, fill = name)) +
geom_bar() +
facet_grid(name ~ .)

## ----lc-barplot-facet, type='learncheck', engine="block"-----------------
**_Learning check_**

## ----viz-map, echo=FALSE, fig.cap="Mind map for Data Visualization", out.width="200%"----
#library(knitr)
#if(knitr:::is_html_output()){
# include_url("https://coggle.it/diagram/V_G2gzukTDoQ-aZt-",
# height = "1000px")
#} else {
include_graphics("images/coggleviz.png", dpi = 300)
#}

## ----include=FALSE, eval=FALSE-------------------------------------------
## knitr::purl("04-viz.Rmd", "docs/scripts/04-viz.R")

Loading

0 comments on commit f6b757f

Please sign in to comment.