Skip to content

Commit

Permalink
Respond to CRAN notes and warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
elinw committed Oct 30, 2020
1 parent 8bcee3c commit a082be3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
^docs$
^pkgdown$
^\.github$
README.html
index.Rmd
index.html
index.md
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Description: Data related to the Salem Witch Trials
Datasets and tutorials documenting the witch accusations and trials
centered around Salem, Massachusetts in 1692. Originally assembled by
Richard B. Latner of Tulane University for his website
https://www.tulane.edu/~salem/index.html. The data sets include information
<https://www.tulane.edu/~salem/index.html>. The data sets include information
on 152 accused witches, members of the Salem Village Committee,
signatories of petitions related to the events, and tax data for
Salem Village.
Expand All @@ -25,14 +25,15 @@ Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.5.0)
Imports: ggplot2,
dplyr (>= 1.0.0),
stats,
tidyr
Imports:
Suggests:
dplyr (>= 1.0.0),
ggplot2,
knitr,
rmarkdown,
sf
sf,
stats,
tidyr
VignetteBuilder:
knitr
Roxygen: list(markdown = TRUE)
Expand Down
5 changes: 4 additions & 1 deletion pkgdown/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
font-size:80px;
padding-right:60px;
font-family:Meddon;
}
}
#salem- > div > img {
margin-left:15px;
}
72 changes: 37 additions & 35 deletions vignettes/recreating_analyses.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,16 @@ salem_theme <- theme(axis.text.x = element_text(angle = 45, vjust = .5))
```


## Ggplot and the Tidyverse

### Accusations
## Accusations and Executions

The website includes displays of the distribution by month.

#### Histogram and frequency table by month
#### Histogram and frequency table of accusations by month

```{r fig.width=5}
ggplot(data = accused_witches) +
aes(x = Month.of.Accusation.Name) +
geom_bar() +
#geom_dotplot(dotsize = .17, method = "histodot", binwidth = 1, fill = "red") +
labs(title = "Accusations by month", x = "Month") +
scale_x_discrete(drop = FALSE) +
salem_theme
Expand Down Expand Up @@ -110,6 +107,7 @@ monthly_accusations <- accused_witches %>%
group_by(Month.of.Accusation.Name) %>%
summarize(number = n()) %>%
mutate(cumulative = cumsum(number) )
monthly_accusations %>% kable(caption = "Accusations by Month")
ggplot(data = monthly_accusations) +
Expand All @@ -134,36 +132,36 @@ ggplot(data = monthly_accusations) +
monthly_accusations %>%
arrange(desc(number)) %>%
arrange(desc(number)) %>%
mutate(Month.of.Accusation.Name =
factor(Month.of.Accusation.Name,
levels=Month.of.Accusation.Name)) %>%
mutate(pareto_cumulative = cumsum(number) ) %>%
ggplot() +
aes(x = Month.of.Accusation.Name, y = pareto_cumulative) +
geom_point( ) +
geom_path(aes(y=pareto_cumulative, group=1), colour="slateblue1", lty=3, size=0.9) +
labs(title = "Pareto Cumulative Distribution of Accusations by Month")+
geom_path(aes(y=pareto_cumulative, group=1), colour="blue", lty=3, size=0.9) +
labs(title = "Pareto Cumulative Distribution of Accusations by Month") +
salem_theme
monthly_accusations %>%
arrange(desc(number)) %>%
mutate(Month.of.Accusation.Name =
factor(Month.of.Accusation.Name,
levels=Month.of.Accusation.Name)) %>%
levels = Month.of.Accusation.Name)) %>%
mutate(pareto_cumulative = cumsum(number) ) %>%
ggplot() +
aes(x = Month.of.Accusation.Name, y = number) +
geom_col() +
geom_path(aes(y=pareto_cumulative, group=1), colour="slateblue1", lty=3, size=0.9) +
geom_path(aes(y=pareto_cumulative, group = 1), colour = "blue", lty=3, size=0.9) +
labs(title = "Pareto Histogram of Accusations by Month") +
salem_theme
```

#### Chronology of Executions
### Executions

Creating the bar chart of executions over time is similar to creating
that for accusations. Additionally, these are shown as what is
Expand All @@ -176,7 +174,6 @@ to NA or missing) we'll remove the missing cases from the graph.
ggplot(data = na.omit(accused_witches)) +
aes(x = Month.of.Execution.Name) +
geom_bar() +
#geom_dotplot(dotsize = .17, method = "histodot", binwidth = 1, fill = "red") +
labs(title = "Executions by month", x = "Month") +
scale_x_discrete(drop = FALSE) +
salem_theme
Expand Down Expand Up @@ -268,8 +265,6 @@ accused_witches %>% filter(Residence == "Andover") %>%
geom_bar() +
scale_x_discrete(drop=FALSE) +
salem_theme
```

The website encourages examining the period before and after the convening of
Expand Down Expand Up @@ -314,10 +309,16 @@ accused_witches %>%
We can use maps to represent the geographic distribution over time
spatially. The salem_region data set is an sf (simple features) data
set that provides geographic data for the towns in the three Massachuessets
counties represented in our data. Not all of the towns in these three counties
counties represented in our data: Essex, Middlesex and Sussex.

To use this data you will need to install the sf package. The code at the
start of the second code chunk tests for whether you have done this.

Not all of the towns in these three counties
had accusations: the majority did not. The data also include the total
accused for each town and the monthly accused for the towns that ever had an
accusation. However, these figures should _never_ be used outside of maps.
accusation. However, these variables should _never_ be used outside of maps
because the results will be incorrect.
This is because many towns have multiple records. This is especially true if
they include islands, which is common in this region of the state.
These are based on modern municipal boundaries which are close to
Expand All @@ -344,24 +345,25 @@ newdata$TOWN_LABEL <- ifelse(newdata$n_accused == 0, NA, newdata$TOWN_LABEL)
```

```{r fig.width=8, fig.height=8}
p1 <- ggplot(newdata)
p2 <- geom_sf_text(aes(label = TOWN_LABEL), color = "blue", size = 2, nudge_x = 5,
nudge_y = 5, na.rm = TRUE)
p3 <- scale_fill_manual(values = c( "grey", "red"), na.value = "white")
p1 + geom_sf(data = newdata, aes(fill = February.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in February")
p1 + geom_sf(data = newdata, aes(fill = July.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in July")
p1 + geom_sf(data = newdata, aes(fill = August.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in August")
p1 + geom_sf(data = newdata, aes(fill = November.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in November")
if (requireNamespace("sf", quietly = TRUE)) {
p1 <- ggplot(newdata)
p2 <- geom_sf_text(aes(label = TOWN_LABEL), color = "blue", size = 2, nudge_x = 5,
nudge_y = 5, na.rm = TRUE)
p3 <- scale_fill_manual(values = c( "grey", "red"), na.value = "white")
p1 + geom_sf(data = newdata, aes(fill = February.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in February")
p1 + geom_sf(data = newdata, aes(fill = July.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in July")
p1 + geom_sf(data = newdata, aes(fill = August.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in August")
p1 + geom_sf(data = newdata, aes(fill = November.Any), color = "black", size = .1) +
p3 + p2 + labs(title = "Location of Accusations in November")
}
```


Expand Down Expand Up @@ -434,7 +436,7 @@ addmargins( table(salem_village$Petition, salem_village$Church.to.1696,
dnn = c( "Membership", "View")))
```

#### Political Power
### Political Power

As explained on the website, the Village of Salem was governed by a Committee of
Five in addition to the Town Meeting
Expand Down

0 comments on commit a082be3

Please sign in to comment.