Skip to content

Commit

Permalink
various minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andybega committed Sep 5, 2023
1 parent ee601cc commit 031f615
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 18 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ Suggests:
covr,
pkgdown,
DT
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
VignetteBuilder: knitr
URL: https://github.com/andybega/states, https://www.andybeger.com/states/
BugReports: https://github.com/andybega/states/issues
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3

12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@

# states 0.3.1.9000

Several small fixes.

## Bug fixes

- Manually add a "states-packge" alias for the package doc since **roxygen2** does not do this by default anymore.
- Switch from the deprecated `ggplot2::aes_string()` to `ggplot2::aes()` + the `.data` pronoun in `plot_missing()`.
- Fix a **dplyr** join warning in `state_panel()` due to the new "relationship" argument.


# states 0.3.1

- Strip **readr** "spec" attribute from the _cowstates_ and _gwstates_ data. They are both now plain data frames with no attributes. (#22)
Expand All @@ -9,6 +20,7 @@

- `all.equal()` in R 4.1.x (R-devel at this point) will check environments for equivalence as well. This breaks one test since 2e **testthat** relies on `all.equal()` for `expect_equal()`. Moving to testthat 3e fixes this bug. (#26)


# states 0.3.0

- Although the original COW state list does not distinguish micro-states, like the G&W list does, the `cowstates` data now has a microstates coding derived from the G&W coding (#24). This makes it easier, for example, to filter out micro-states from a state panel dataset.
Expand Down
4 changes: 4 additions & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ prettyc <- function(x) {
dict <- matrix(ncol=2, byrow=TRUE, c(
"Burkina Faso \\(Upper Volta\\)", "Burkina Faso",
"Bolivia, Plurinational State of", "Bolivia",
"Cambodia \\(Kampuchea\\)", "Cambodia",
"Central African Republic", "CAR",
"Congo, the Democratic Republic of the", "DR Congo",
"Congo, Democratic Republic of \\(Zaire\\)", "DR Congo",
"Federal Republic of Germany", "Germany",
"Federated States of Micronesia", "Micronesia",
"German Federal Republic", "Germany",
"Korea, Democratic People's Republic of", "North Korea",
"Korea, People's Republic of", "North Korea",
"Korea, Republic of", "South Korea",
Expand All @@ -138,7 +140,9 @@ prettyc <- function(x) {
"Myanmar \\(Burma\\)", "Myanmar",
"Iran, Islamic Republic of", "Iran",
"Iran \\(Persia\\)", "Iran",
"Italy/Sardinia", "Italy",
"Russian Federation", "Russia",
"Russia \\(Soviet Union\\)", "Russia",
"Sri Lanka \\(Ceylon\\)", "Sri Lanka",
"Syrian Arab Republic", "Syria",
"Tanzania, United Republic of", "Tanzania",
Expand Down
3 changes: 2 additions & 1 deletion R/plot-missing.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ plot_missing <- function(data, x = NULL, ccode = NULL, time = NULL,
brks <- sort(unique(mm[, ccode]), decreasing = T)
brks <- brks[seq(1, length(brks), by = skip_labels)]

p <- ggplot2::ggplot(mm, ggplot2::aes_string(x = time, y = ccode, fill = "status")) +
p <- ggplot2::ggplot(mm, ggplot2::aes(x = .data[[time]], y = .data[[ccode]],
fill = "status")) +
ggplot2::geom_tile() +
ggplot2::scale_y_discrete(breaks = brks) +
ggplot2::scale_x_date(expand=c(0, 0)) +
Expand Down
3 changes: 2 additions & 1 deletion R/state-panel.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ state_panel_date <- function(start, end, by, partial, useGW) {
dates <- data.frame(date = seq(start, end, by = by), dummy = 1)

statelist$dummy <- 1
super_panel <- dplyr::full_join(statelist, dates, by = "dummy")
super_panel <- dplyr::full_join(statelist, dates, by = "dummy",
relationship = "many-to-many")
super_panel$dummy <- NULL

# Cut excess non-independent country-years from panel
Expand Down
3 changes: 3 additions & 0 deletions R/states-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
#'
#' @name states
#' @docType package
#' @aliases states-package
#'
#' @importFrom utils tail
#' @importFrom rlang .data
NULL

globalVariables(c("gwstates", "cowstates"))
2 changes: 0 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,3 @@ Gleditsch, Kristian S. & Michael D. Ward. 1999. "Interstate System Membership: A
For the [Correlates of War (COW) state data](https://correlatesofwar.org/data-sets/state-system-membership):

Correlates of War Project. 2017. "State System Membership List, v2016." Online, https://correlatesofwar.org


19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ merging different data sources:

What the package does:

- It contains the Gleditsch and Ward (G&W) as well as the Correlates
of War (COW) state system membership lists.
- It contains the Gleditsch and Ward (G&W) as well as the Correlates of
War (COW) state system membership lists.

``` r
library("states")
Expand All @@ -38,7 +38,7 @@ data(gwstates)
data(cowstates)
```

- Search them with `sfind`, this can be helpful for manual coding:
- Search them with `sfind`, this can be helpful for manual coding:

``` r
sfind(260)[, 1:6]
Expand All @@ -56,8 +56,8 @@ sfind("German")[, 1:6]
#> 300 COW 265 GDR German Democratic Republic 1954-03-25 1990-10-02
```

- You can use it to build a country-year template that matches either
the COW or G&W state lists.
- You can use it to build a country-year template that matches either
the COW or G&W state lists.

``` r
countries <- state_panel(1991, 2001)
Expand All @@ -68,9 +68,9 @@ str(countries)
#> $ year : int 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 ...
```

- Visualize missing/non-independent cases in your data. See this
related [blog post for more
details](https://www.andybeger.com/2016/09/14/data-management-and-missing-data/).
- Visualize missing/non-independent cases in your data. See this related
[blog post for more
details](https://www.andybeger.com/2016/09/14/data-management-and-missing-data/).

``` r
data("polity")
Expand Down Expand Up @@ -130,5 +130,4 @@ For the [Correlates of War (COW) state
data](https://correlatesofwar.org/data-sets/state-system-membership):

Correlates of War Project. 2017. “State System Membership List, v2016.”
Online,
<a href="https://correlatesofwar.org" class="uri">https://correlatesofwar.org</a>
Online, <https://correlatesofwar.org>
5 changes: 3 additions & 2 deletions man/states.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions release-prep.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Notes to prep for release
=========================

```r
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
devtools::check_win_release()
ch <- rhub::check_for_cran()
Expand Down

0 comments on commit 031f615

Please sign in to comment.