Skip to content

Commit

Permalink
Updates to class() calls (#359)
Browse files Browse the repository at this point in the history
* class updates

* Update test-watchdog_testfiles.R

* Re-build README.Rmd

* Further updates to class vs inherits

* Delete visR.pdf

Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: shaesen2 <shaesen2@its.jnj.com>
  • Loading branch information
3 people authored Apr 25, 2022
1 parent 4f9adfa commit e097964
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 168 deletions.
12 changes: 5 additions & 7 deletions R/add_highlight.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ add_highlight.ggsurvfit <- function(gg = NULL,
# https://www.r-bloggers.com/2019/08/no-visible-binding-for-global-variable/#option-two
alpha <- colour <- fill <- group <- NULL

if (!("ggplot" %in% class(gg))) {

if (!inherits(gg, "ggplot")) {
stop("A 'ggplot' has to be specified for 'gg'.")

}

if (missing(strata) | length(strata) == 0) {
Expand All @@ -60,15 +58,15 @@ add_highlight.ggsurvfit <- function(gg = NULL,

if (length(strata) == 1) {

if (class(strata) == "list") {
if (inherits(strata, "list")) {

if (class(strata[[1]]) != "character") {
if (!inherits(strata, "character")) {

stop("A 'strata' must be either a single character string or a list of them.")

}

} else if (!(class(strata) == "character")) {
} else if (!inherits(strata, "character")) {

stop("A 'strata' must be either a single character string or a list of them.")

Expand All @@ -84,7 +82,7 @@ add_highlight.ggsurvfit <- function(gg = NULL,

base::sapply(strata, function(s) {

if (class(s) != "character") {
if (!inherits(s, "character")) {

stop("When 'strata' is a list, all elements must be character strings.")

Expand Down
4 changes: 2 additions & 2 deletions R/apply_theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ define_theme <- function(strata = NULL,

}

base::class(theme) <- base::append(base::class(theme), "visR_theme")
base::class(theme) <- c( "visR_theme", class(theme))

return(theme)

Expand Down Expand Up @@ -255,7 +255,7 @@ apply_theme <- function(gg, visR_theme_dict = NULL) {

if (!is.null(visR_theme_dict)) {

if (!("visR_theme" %in% base::class(visR_theme_dict))) {
if (!inherits(visR_theme_dict, "visR_theme")) {

base::message("It is recommended to generate the theme object through `visR::define_theme`. Attempting to use the provided object anyway.")

Expand Down
2 changes: 1 addition & 1 deletion R/get_attrition.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ get_attrition <- function(
criteria_conditions,
subject_column_name){

if ( class(subject_column_name) != "character" | length(subject_column_name) > 1) {
if (!inherits(subject_column_name, "character") || length(subject_column_name) > 1) {

stop("The 'subject_column_name' argument has to be a string. Please correct the 'subject_column_name' and re-run the function")

Expand Down
Loading

0 comments on commit e097964

Please sign in to comment.