Skip to content

Commit

Permalink
make apslit conditional in vignette and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hturner committed Sep 16, 2019
1 parent 284b58f commit 1ca82bb
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 19 deletions.
4 changes: 2 additions & 2 deletions R/pudding.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#' # ties: use an array list (easier with R >= 3.6.0)
#' if (getRversion() < "3.6.0"){
#' n <- nrow(pudding)
#' ties <- data.frame(Winner = array(split(pudding[, c("i", "j")], 1:n, n)),
#' ties <- data.frame(Winner = array(split(pudding[c("i", "j")], 1:n), n),
#' Loser = rep(NA, 15))
#' } else {
#' ties <- data.frame(Winner = asplit(pudding[, c("i", "j")], 1),
#' ties <- data.frame(Winner = asplit(pudding[c("i", "j")], 1),
#' Loser = rep(NA, 15))
#' }
#' head(ties, 2)
Expand Down
11 changes: 9 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Comments

This submission is mainly to fix a bug in the vcov method that causes NA values for a particular parameterization. Some other minor fixes and improvements have been made at the same time.
This submission:
- uses alternative to base::asplit in R < 3.6.0 (to fix errors on CRAN)
- fixes bug in vcov method that causes NA values for a particular parameterization.

Some other minor fixes and improvements have been made at the same time.

## Test environments

Expand All @@ -10,10 +14,13 @@ This submission is mainly to fix a bug in the vcov method that causes NA values
4. (R-hub) Windows Server 2008 R2 SP1, R-devel, 32/64 bit
5. (R-hub) macOS 10.11 El Capitan, R-release
6. (Win-builder) Windows Server 2008 (64-bit), R-devel
7. (Win-builder) Windows Server 2008 (64-bit), R-oldrelease

### Check results

Check 3, 4 & 6 returns a note regarding URLs/DOIs. This is a false alarm: all the links redirect to valid pages on jstor.
Checks 3, 4, 6 & 7 return a note regarding URLs/DOIs. This is a false alarm: all the links redirect to valid pages on jstor.org.

Check 7 gives an additional note: "no visible global function definition for 'asplit'". However, the code conditions on R version, so asplit is only called if R >= 3.6.0. This conditional execution is validated by the fact that the examples and tests do not fail on this installation, which has R-3.5.3.

## revdepcheck results

Expand Down
18 changes: 12 additions & 6 deletions docs/articles/Overview.html

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

Binary file modified docs/articles/Overview_files/figure-html/always-loses-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions man/pudding.Rd

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

10 changes: 8 additions & 2 deletions tests/testthat/test-vcov.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,14 @@ test_that("vcov.PlackettLuce works w/ different ref [pudding]", {
# create orderings for each set of paired comparisons
i_wins <- data.frame(Winner = pudding$i, Loser = pudding$j)
j_wins <- data.frame(Winner = pudding$j, Loser = pudding$i)
ties <- data.frame(Winner = asplit(pudding[, c("i", "j")], 1),
Loser = rep(NA, 15))
if (getRversion() < "3.6.0"){
n <- nrow(pudding)
ties <- data.frame(Winner = array(split(pudding[c("i", "j")], 1:n), n),
Loser = rep(NA, 15))
} else {
ties <- data.frame(Winner = asplit(pudding[c("i", "j")], 1),
Loser = rep(NA, 15))
}
# convert to rankings
R <- as.rankings(rbind(i_wins, j_wins, ties),
input = "orderings")
Expand Down
16 changes: 11 additions & 5 deletions vignettes/Overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,19 @@ corresponding to the wins for item $i$, the wins for item $j$ and the ties:
```{r}
i_wins <- data.frame(Winner = pudding$i, Loser = pudding$j)
j_wins <- data.frame(Winner = pudding$j, Loser = pudding$i)
ties <- data.frame(Winner = asplit(pudding[, c("i", "j")], 1),
Loser = rep(NA, 15))
if (getRversion() < "3.6.0"){
n <- nrow(pudding)
ties <- data.frame(Winner = array(split(pudding[c("i", "j")], 1:n), n),
Loser = rep(NA, 15))
} else {
ties <- data.frame(Winner = asplit(pudding[c("i", "j")], 1),
Loser = rep(NA, 15))
}
head(ties, 2)
```
In the last case, the base R function `asplit` is used to split the `i` and `j`
columns of `pudding` by row, giving a vector of items that we can specify as
the winner, while the loser is missing.
In the last case, we split the `i` and `j` columns of `pudding` by row, using
the base R function `asplit`, if available. For each pair, this gives a vector
of items that we can specify as the winner, while the loser is missing.

Now the `as.rankings()` function from **PlackettLuce** can be used to convert
the combined orderings to an object of class `"rankings"`.
Expand Down

0 comments on commit 1ca82bb

Please sign in to comment.