Skip to content

Commit

Permalink
fix cran issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Sep 15, 2024
1 parent d777de6 commit 4f78206
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 54 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ Suggests:
transformr
License: GPL (>= 3)
Language: en-US
BugReports: https://github.com/mjskay/tidybayes/issues/new
BugReports: https://github.com/mjskay/tidybayes/issues
URL: https://mjskay.github.io/tidybayes/, https://github.com/mjskay/tidybayes/
VignetteBuilder: knitr
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
LazyData: true
Encoding: UTF-8
Collate:
Expand Down
2 changes: 1 addition & 1 deletion R/compose_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ as_data_list.data_list = function(object, name="", ...) {
#' \item all other types are dropped (and a warning given)
#' }
#'
#' As in functions like [mutate()], each expression is evaluated in an
#' As in functions like [dplyr::mutate()], each expression is evaluated in an
#' environment containing the data list built up so far.
#'
#' For example, this means that if the first argument to `compose_data`
Expand Down
10 changes: 5 additions & 5 deletions R/nest_rvars.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
#' and `.iteration` columns) indexing draws. It should be a grouped by any
#' columns that are not intended to be nested.
#' - For `unnest_rvars()`, the data frame should have at least one column that
#' is an [`rvar`]; all `rvar` columns will be unnested.
#' is an [`rvar`][posterior::rvar]; all `rvar` columns will be unnested.
#'
#' @return
#'
#' For `nest_rvars()`, returns a data frame without `.chain`, `.iteration`, and
#' `.draw` columns, where all non-grouped columns have been converted to [`rvar`]s.
#' `.draw` columns, where all non-grouped columns have been converted to [`rvar`][posterior::rvar]s.
#'
#' For `unnest_rvars()`, returns a data frame with `.chain`, `.iteration`, and
#' `.draw` columns added, where every [`rvar`] column in the input has been
#' converted to (one or more) columns containing draws from those [`rvar`]s
#' in long format. The result is grouped by all non-[`rvar`] columns in the
#' `.draw` columns added, where every [`rvar`][posterior::rvar] column in the input has been
#' converted to (one or more) columns containing draws from those [`rvar`][posterior::rvar]s
#' in long format. The result is grouped by all non-[`rvar`][posterior::rvar] columns in the
#' input; this ensures that `nest_rvars(unnest_rvars(x))` returns `x`.
#'
#' @examples
Expand Down
8 changes: 4 additions & 4 deletions R/predict_curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' The function generates a predictive curve given posterior draws
#' (`data`), an expression (`formula`), and a set of variables
#' defining the curve (`...`). For every group in `data` (if it is a
#' grouped data frame---see [group_by()]; otherwise the entire data
#' grouped data frame---see [group_by()][dplyr::group_by]; otherwise the entire data
#' frame is taken at once), and for each combination of values in `...`,
#' the right-hand side of `formula` is evaluated and its results passed to
#' the `summary` function. This allows a predictive curve to be generated,
Expand All @@ -33,10 +33,10 @@
#' convenient argument for adjusting the number of bins per point on the
#' curve.
#'
#' @param data A [data.frame], [tbl_df] or
#' [grouped_df] representing posteriors from a Bayesian model as
#' @param data A [`data.frame`], [`tibble`][tibble::tibble], or
#' [`grouped_df`][dplyr::grouped_df] representing posteriors from a Bayesian model as
#' might be obtained through [spread_draws()]. Grouped data frames
#' as returned by [group_by()] are supported.
#' as returned by [group_by()][dplyr::group_by] are supported.
#' @param formula A formula specifying the prediction curve. The left-hand side
#' of the formula should be a name representing the name of the column that
#' will hold the predicted response in the returned data frame. The right-hand
Expand Down
8 changes: 4 additions & 4 deletions R/predicted_rvars.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

#' Add `rvar`s for the linear predictor, posterior expectation, posterior predictive, or residuals of a model to a data frame
#'
#' Given a data frame and a model, adds [`rvar`]s of draws from the linear/link-level predictor,
#' Given a data frame and a model, adds [`rvar`][posterior::rvar]s of draws from the linear/link-level predictor,
#' the expectation of the posterior predictive, or the posterior predictive to
#' the data frame.
#'
#' @templateVar pred_type rvars
#' @templateVar draws [`rvar`]s containing draws
#' @templateVar draws [`rvar`][posterior::rvar]s containing draws
#' @template details-pred
#' @template param-pred-newdata
#' @template param-pred-object
Expand All @@ -32,10 +32,10 @@
#' correspond to the same row in `newdata`.
#' See `vignette("tidy-posterior")` for examples of dealing with output ordinal models.
#' @return A data frame (actually, a [tibble][tibble::tibble]) equal to the input `newdata` with
#' additional columns added containing [`rvar`]s representing the requested predictions or fits.
#' additional columns added containing [`rvar`][posterior::rvar]s representing the requested predictions or fits.
#' @author Matthew Kay
#' @seealso [add_predicted_draws()] for the analogous functions that use a long-data-frame-of-draws
#' format instead of a data-frame-of-`rvar`s format. See [spread_rvars()] for manipulating posteriors directly.
#' format instead of a data-frame-of-[`rvar`][posterior::rvar]s format. See [spread_rvars()] for manipulating posteriors directly.
#' @keywords manip
#' @examples
#' \dontrun{
Expand Down
2 changes: 1 addition & 1 deletion R/spread_draws.R
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ nest_dimensions_ = function(
}

if (reindex) {
is_character_index = is.character(indices)
is_character_index = is.character(indices) || is.factor(indices)

#create a template list that we can use to re-index the values
template_vector = long_draws[[value_name]][[1]][[1]]
Expand Down
10 changes: 5 additions & 5 deletions R/spread_rvars.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' they will have multiple columns with names like `"b[1,1]"`, `"b[2,1]"`, etc.
#'
#' `spread_rvars` and `gather_rvars` provide a straightforward
#' syntax to translate these columns back into properly-indexed [`rvar`]s in two different
#' syntax to translate these columns back into properly-indexed [`rvar`][posterior::rvar]s in two different
#' tidy data frame formats, optionally recovering dimension types (e.g. factor levels) as it does so.
#'
#' `spread_rvars` will spread names of variables in the model across the data frame as column names,
Expand All @@ -31,8 +31,8 @@
#' \itemize{
#' \item column `"i"`: value in `1:5`
#' \item column `"v"`: value in `1:10`
#' \item column `"a"`: [rvar] containing draws from `"a[i]"`
#' \item column `"b"`: [rvar] containing draws from `"b[i,v]"`
#' \item column `"a"`: [`rvar`][posterior::rvar] containing draws from `"a[i]"`
#' \item column `"b"`: [`rvar`][posterior::rvar] containing draws from `"b[i,v]"`
#' }
#'
#' `gather_rvars(model, a[i], b[i,v])` on the same model would return a data frame with:
Expand All @@ -41,7 +41,7 @@
#' \item column `"v"`: value in `1:10`, or `NA`
#' on rows where `".variable"` is `"a"`.
#' \item column `".variable"`: value in `c("a", "b")`.
#' \item column `".value"`: [rvar] containing draws from `"a[i]"` (when `".variable"` is `"a"`)
#' \item column `".value"`: [`rvar`][posterior::rvar] containing draws from `"a[i]"` (when `".variable"` is `"a"`)
#' or `"b[i,v]"` (when `".variable"` is `"b"`)
#' }
#'
Expand Down Expand Up @@ -100,7 +100,7 @@
#' Besides being more compact, the `c()`-style syntax is currently also slightly
#' faster (though that may change).
#'
#' Dimensions can be left nested in the resulting [rvar] objects by leaving their names
#' Dimensions can be left nested in the resulting [`rvar`][posterior::rvar] objects by leaving their names
#' blank; e.g. `spread_rvars(model, b[i,])` will place the first index (`i`) into
#' rows of the data frame but leave the second index nested in the `b` column
#' (see *Examples* below).
Expand Down
9 changes: 9 additions & 0 deletions R/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
# Author: mjskay
###############################################################################


# skips -------------------------------------------------------------------

#' skip tests sensitive to minor changes in density() in R 4.4
#' @noRd
skip_if_sensitive_to_density = function() {
testthat::skip_if(getRversion() < "4.4", "density() output changed in R 4.4")
}

# skip tests if there is no vdiffr setup or if the setup is likely
# to produce false positive test failures (e.g. old version of ggplot2)
skip_if_no_vdiffr = function() {
Expand Down
12 changes: 6 additions & 6 deletions man/add_predicted_rvars.Rd

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

2 changes: 1 addition & 1 deletion man/compose_data.Rd

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

10 changes: 5 additions & 5 deletions man/nest_rvars.Rd

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

8 changes: 4 additions & 4 deletions man/predict_curve.Rd

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

10 changes: 5 additions & 5 deletions man/spread_rvars.Rd

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

2 changes: 1 addition & 1 deletion man/tidybayes-package.Rd

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4f78206

Please sign in to comment.