Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/gg_partial.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
#' multiple partial plot objects in figures.
#'
#' @export
gg_partial = function(part_dta,

Check warning on line 11 in R/gg_partial.R

View workflow job for this annotation

GitHub Actions / lint

file=R/gg_partial.R,line=11,col=12,[assignment_linter] Use one of <-, <<- for assignment, not =.
nvars = NULL,
cat_limit = 10,
model = NULL) {
## Prepare the partial dependencies data for panel plots
if (is.null(nvars)) {
nvars = length(part_dta$plotthis)

Check warning on line 17 in R/gg_partial.R

View workflow job for this annotation

GitHub Actions / lint

file=R/gg_partial.R,line=17,col=11,[assignment_linter] Use one of <-, <<- for assignment, not =.
}

Check warning on line 19 in R/gg_partial.R

View workflow job for this annotation

GitHub Actions / lint

file=R/gg_partial.R,line=19,col=1,[trailing_whitespace_linter] Remove trailing whitespace.
cont_list = list()

Check warning on line 20 in R/gg_partial.R

View workflow job for this annotation

GitHub Actions / lint

file=R/gg_partial.R,line=20,col=13,[assignment_linter] Use one of <-, <<- for assignment, not =.
cat_list = list()
for (feature in seq(nvars)) {
## Format any continuous features (those with fewer than cat_limit unique values)
if (length(unique(part_dta$plotthis[[feature]]$x)) > cat_limit) {
plt.df = as.data.frame(cbind(
plt.df = dplyr::bind_cols(
x = part_dta$plotthis[[feature]]$x,
yhat = part_dta$plotthis[[feature]]$yhat
))
)
plt.df$name = names(part_dta$plotthis)[[feature]]

cont_list[[feature]] <- plt.df
Expand All @@ -34,10 +34,10 @@

## Though VarPro works with logical or continuous only. Factors are
## one hot encoded internal to the varPro call.
plt.df = as.data.frame(cbind(
plt.df = dplyr::bind_cols(
x = factor(part_dta$plotthis[[feature]]$x),
yhat = part_dta$plotthis[[feature]]$yhat
))
)
plt.df$name = names(part_dta$plotthis)[[feature]]

cat_list[[feature]] <- plt.df
Expand Down
29 changes: 13 additions & 16 deletions R/gg_partialpro.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ gg_partialpro = function(part_dta,
for (feature in seq(nvars)) {
## Format any continuous features (those with fewer than 10 unique values)
if (length(part_dta[[feature]]$xvirtual) > cat_limit) {
plt.df = as.data.frame(
cbind(
variable = part_dta[[feature]]$xvirtual,
parametric = colMeans(part_dta[[feature]]$yhat.par, na.rm =
TRUE),
nonparametric = colMeans(part_dta[[feature]]$yhat.nonpar, na.rm =
TRUE),
causal = colMeans(part_dta[[feature]]$yhat.causal, na.rm =
TRUE)
)
plt.df = dplyr::bind_cols(
variable = part_dta[[feature]]$xvirtual,
parametric = colMeans(part_dta[[feature]]$yhat.par, na.rm =
TRUE),
nonparametric = colMeans(part_dta[[feature]]$yhat.nonpar, na.rm =
TRUE),
causal = colMeans(part_dta[[feature]]$yhat.causal, na.rm =
TRUE)
)

plt.df$name = names(part_dta)[[feature]]

cont_list[[feature]] <- plt.df
Expand All @@ -46,12 +45,10 @@ gg_partialpro = function(part_dta,
cat_feat = list()
## Each yhat has at least 2 columns, for logical values...
for (ind in seq(length(unique(part_dta[[feature]]$xorg)))) {
cat_feat[[ind]] = as.data.frame(
cbind(
parametric = part_dta[[feature]]$yhat.par[, ind],
nonparametric = part_dta[[feature]]$yhat.nonpar[, ind],
causal = part_dta[[feature]]$yhat.causal[, ind]
)
cat_feat[[ind]] = dplyr::bind_cols(
parametric = part_dta[[feature]]$yhat.par[, ind],
nonparametric = part_dta[[feature]]$yhat.nonpar[, ind],
causal = part_dta[[feature]]$yhat.causal[, ind]
)
cat_feat[[ind]]$variable <-
unique(part_dta[[feature]]$xorg)[ind]
Expand Down
Loading