diff --git a/R/pudding.R b/R/pudding.R index ea3c208..151df21 100644 --- a/R/pudding.R +++ b/R/pudding.R @@ -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) diff --git a/cran-comments.md b/cran-comments.md index 51c6814..02ee792 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -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 @@ -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 diff --git a/docs/articles/Overview.html b/docs/articles/Overview.html index cf8ace2..d21824a 100644 --- a/docs/articles/Overview.html +++ b/docs/articles/Overview.html @@ -634,15 +634,21 @@

corresponding to the wins for item \(i\), the wins for item \(j\) and the ties:

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))
-head(ties, 2)
+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)
##   Winner Loser
 ## 1   1, 2    NA
 ## 2   1, 3    NA
-

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".

R <- as.rankings(rbind(i_wins, j_wins, ties),
diff --git a/docs/articles/Overview_files/figure-html/always-loses-1.png b/docs/articles/Overview_files/figure-html/always-loses-1.png
index f944121..059ff93 100644
Binary files a/docs/articles/Overview_files/figure-html/always-loses-1.png and b/docs/articles/Overview_files/figure-html/always-loses-1.png differ
diff --git a/man/pudding.Rd b/man/pudding.Rd
index 7cb9c74..3a28d45 100644
--- a/man/pudding.Rd
+++ b/man/pudding.Rd
@@ -33,10 +33,10 @@ j_wins <- data.frame(Winner = pudding$j, Loser = pudding$i)
 # 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)
diff --git a/tests/testthat/test-vcov.R b/tests/testthat/test-vcov.R
index 74c8809..f4f6da9 100644
--- a/tests/testthat/test-vcov.R
+++ b/tests/testthat/test-vcov.R
@@ -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")
diff --git a/vignettes/Overview.Rmd b/vignettes/Overview.Rmd
index f1b2ca4..816a163 100644
--- a/vignettes/Overview.Rmd
+++ b/vignettes/Overview.Rmd
@@ -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"`.