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
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export(gg_error)
export(gg_error.randomForest)
export(gg_error.randomForest.formula)
export(gg_error.rfsrc)
export(gg_partial_df)
export(gg_partialpro_df)
export(gg_partial)
export(gg_partialpro)
export(gg_rfsrc)
export(gg_roc)
export(gg_survival)
Expand Down
40 changes: 18 additions & 22 deletions R/gg_partial_df.R → R/gg_partial.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
#' Split partial lots into continuous or categorical datasets
#' @param part_dta partial plot data from \code{rfsrc::plot.variable}
#' @param nvars how many of the partial plot variables to calculate
#' @param cat_limit Categorical features are build when there are fewer than
#' @param cat_limit Categorical features are build when there are fewer than
#' cat_limit unique features.
#' @param name a label name applied to all features. Useful when combining
#' @param model a label name applied to all features. Useful when combining
#' multiple partial plot objects in figures.
#'
#'
#' @export
gg_partial_df = function(part_dta, nvars = NULL, cat_limit = 10, name=NULL) {
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(
x = part_dta$plotthis[[feature]]$x,
yhat = part_dta$plotthis[[feature]]$yhat
)
)
plt.df = as.data.frame(cbind(
x = part_dta$plotthis[[feature]]$x,
yhat = part_dta$plotthis[[feature]]$yhat
))

Check warning on line 28 in R/gg_partial.R

View check run for this annotation

Codecov / codecov/patch

R/gg_partial.R#L25-L28

Added lines #L25 - L28 were not covered by tests
plt.df$name = names(part_dta$plotthis)[[feature]]

cont_list[[feature]] <- plt.df
Expand All @@ -33,12 +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(
x = factor(part_dta$plotthis[[feature]]$x),
yhat = part_dta$plotthis[[feature]]$yhat
)
)
plt.df = as.data.frame(cbind(
x = factor(part_dta$plotthis[[feature]]$x),
yhat = part_dta$plotthis[[feature]]$yhat
))

Check warning on line 40 in R/gg_partial.R

View check run for this annotation

Codecov / codecov/patch

R/gg_partial.R#L37-L40

Added lines #L37 - L40 were not covered by tests
plt.df$name = names(part_dta$plotthis)[[feature]]

cat_list[[feature]] <- plt.df
Expand All @@ -47,12 +46,9 @@
continuous = dplyr::bind_rows(cont_list)
categorical = dplyr::bind_rows(cat_list)

if(!is.na(name)){
continuous$model <- categorical$model <- name
if (!is.null(model)) {
continuous$model <- categorical$model <- model

Check warning on line 50 in R/gg_partial.R

View check run for this annotation

Codecov / codecov/patch

R/gg_partial.R#L49-L50

Added lines #L49 - L50 were not covered by tests
}

return(list(
continuous = continuous,
categorical = categorical
))
return(list(continuous = continuous, categorical = categorical))

Check warning on line 53 in R/gg_partial.R

View check run for this annotation

Codecov / codecov/patch

R/gg_partial.R#L53

Added line #L53 was not covered by tests
}
22 changes: 11 additions & 11 deletions R/gg_partialpro_df.R → R/gg_partialpro.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
#' Split partial lots into continuous or categorical datasets
#' @param part_dta partial plot data from \code{varpro::partialpro}
#' @param nvars how many of the partial plot variables to calculate
#' @param cat_limit Categorical features are build when there are fewer than
#' @param cat_limit Categorical features are build when there are fewer than
#' cat_limit unique features.
#' @param name a label name applied to all features. Useful when combining
#' @param model a label name applied to all features. Useful when combining
#' multiple partial plot objects in figures.
#'
#'
#' @export
#'
gg_partialpro_df = function(part_dta, nvars = NULL, cat_limit=10, name=NULL) {
#'
gg_partialpro = function(part_dta,
nvars = NULL,
cat_limit = 10,
model = NULL) {
## Prepare the partial pro dependencies data for panel plots
if (is.null(nvars)) {
nvars = length(part_dta)
Expand Down Expand Up @@ -68,12 +71,9 @@
continuous = dplyr::bind_rows(cont_list)
categorical = dplyr::bind_rows(cat_list)

if(!is.na(name)){
continuous$model <- categorical$model <- name
if (!is.null(model)) {
continuous$model <- categorical$model <- model

Check warning on line 75 in R/gg_partialpro.R

View check run for this annotation

Codecov / codecov/patch

R/gg_partialpro.R#L74-L75

Added lines #L74 - L75 were not covered by tests
}

return(list(
continuous = continuous,
categorical = categorical
))
return(list(continuous = continuous, categorical = categorical))

Check warning on line 78 in R/gg_partialpro.R

View check run for this annotation

Codecov / codecov/patch

R/gg_partialpro.R#L78

Added line #L78 was not covered by tests
}
12 changes: 6 additions & 6 deletions man/gg_partial_df.Rd → man/gg_partial.Rd

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

12 changes: 6 additions & 6 deletions man/gg_partialpro_df.Rd → man/gg_partialpro.Rd

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

Loading