Skip to content

Commit

Permalink
Merge pull request #16 from olivroy/assertthat
Browse files Browse the repository at this point in the history
Remove deprecated + other cleanup
  • Loading branch information
rolkra committed Sep 4, 2023
2 parents afb33da + 17b41c4 commit f7145b6
Show file tree
Hide file tree
Showing 42 changed files with 372 additions and 477 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
49 changes: 49 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
43 changes: 23 additions & 20 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,34 @@ Description: Interactive data exploration with one line of code or use an easy
automated report.
License: GPL-3
Encoding: UTF-8
URL: https://github.com/rolkra/explore/
URL: https://github.com/rolkra/explore
Depends: R (>= 3.5.0)
Imports:
assertthat,
broom,
dplyr,
DT (>= 0.3.0),
forcats,
ggplot2 (>= 3.0.0),
gridExtra,
magrittr,
MASS,
assertthat,
broom,
dplyr,
DT (>= 0.3.0),
forcats,
ggplot2 (>= 3.4.0),
gridExtra,
magrittr,
MASS,
palmerpenguins,
randomForest,
rlang,
rmarkdown,
rpart,
rpart.plot,
shiny,
rlang,
rmarkdown,
rpart,
rpart.plot,
shiny,
stats,
stringr,
tibble,
tidyr
RoxygenNote: 7.2.1
stringr,
tibble,
tidyr
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Suggests:
knitr,
testthat
testthat (>= 3.0.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
BugReports: https://github.com/rolkra/explore/issues
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import(shiny)
importFrom(DT,DTOutput)
importFrom(DT,renderDT)
importFrom(forcats,fct_reorder)
importFrom(graphics,legend)
importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,text)
importFrom(gridExtra,grid.arrange)
Expand Down
10 changes: 5 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* add predict_target()
* add create_data_newsletter()
* add use_data_*() functions
* drop use of fct_explicit_na() (deprecated)
* drop use of `fct_explicit_na()` (deprecated) (#15)
* create_data use_data return datasets as tibble

## explore 1.0.2 (2023-01-14)
Expand Down Expand Up @@ -48,7 +48,7 @@

* rename create_x_data() to create_data_x()
* rename add_x_var() to add_var_x()
* extend create_data funtions
* extend create_data functions
* extend add_var functions
* explain_tree(): set default minsplit to 20
* explain_tree(): set prior probabilities
Expand Down Expand Up @@ -151,10 +151,10 @@ Maintenance update:

## explore 0.5.2 (2019-11-21)

* split scource-code file into multiple files
* split source-code file into multiple files
* format_num_auto without brackets
* treat Date variables as cat
* report() fix automatic file extentison .html
* report() fix automatic file extension .html
* add simplify_text()
* add parameter simplify_text to clean_var()
* fix link in README.md
Expand Down Expand Up @@ -216,7 +216,7 @@ Many functions now accept categorical and numerical targets (next to a binary ta
* parameter split: default = FALSE
* allow numeric (num) target in explore_all & report
* describe_tbl() -> fix target if not bin
* desribe(): change out="vector" to out="list"
* describe(): change out="vector" to out="list"

## explore 0.4.3 (2019-06-20)

Expand Down
40 changes: 14 additions & 26 deletions R/abtest.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,22 @@
abtest <- function(data, expr, target, sign_level = 0.05) {

# check parameter
assertthat::assert_that(!missing(data), msg = "expect data to abtest")
rlang::check_required(data)
rlang::check_required(expr)
rlang::check_required(target)

assertthat::assert_that(is.data.frame(data), msg = "expect data of type data.frame")
assertthat::assert_that(nrow(data) > 0, msg = "data has 0 observations")
assertthat::assert_that(!missing(expr), msg = "expect an logical expression to abtest")
assertthat::assert_that(!missing(target), msg = "expect a target variable to abtest")
assertthat::assert_that(is.numeric(sign_level), msg = "expect numeric value for sign_level")
assertthat::assert_that(sign_level <= 1, msg = "expect sign_level between 0 and 1")
assertthat::assert_that(sign_level > 0, msg = "expect sign_level between 0 and 1")


# parameter target
if (!missing(target)) {
target_quo <- enquo(target)
target_txt <- quo_name(target_quo)[[1]]
if (!target_txt %in% names(data)) {
stop(paste0("target variable '", target_txt, "' not found in data"))
}
} else {
target_txt <- NA
target_quo <- enquo(target)
target_txt <- quo_name(target_quo)[[1]]
if (!target_txt %in% names(data)) {
stop(paste0("target variable '", target_txt, "' not found in data"))
}

# check if target is cat/num
Expand Down Expand Up @@ -75,14 +72,10 @@ abtest <- function(data, expr, target, sign_level = 0.05) {

abtest_targetnum <- function(data, expr, target, sign_level = 0.05) {

rlang::check_required(target)
# parameter target
if (!missing(target)) {
target_quo <- enquo(target)
target_txt <- quo_name(target_quo)[[1]]
} else {
stop("parameter target is missing")
return(NA)
}
target_quo <- enquo(target)
target_txt <- quo_name(target_quo)[[1]]

# define variables for CRAN-package check
target_mean <- NULL
Expand Down Expand Up @@ -210,15 +203,10 @@ abtest_targetnum <- function(data, expr, target, sign_level = 0.05) {
#' abtest(data, age >= 40, target = buy)

abtest_targetpct <- function(data, expr, target, sign_level = 0.05) {

# parameter target
if (!missing(target)) {
target_quo <- enquo(target)
target_txt <- quo_name(target_quo)[[1]]
} else {
stop("parameter target is missing")
return(NA)
}
rlang::check_required(target)
target_quo <- enquo(target)
target_txt <- quo_name(target_quo)[[1]]

# define variables for CRAN-package check
target1_sum <- NULL
Expand Down
8 changes: 2 additions & 6 deletions R/add-var.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ add_var_random_cat <- function(data,
seed) {

# data table available?
if (missing(data)) {
stop("data is missing")
}
rlang::check_required(data)

if (!is.data.frame(data)) {
stop("expect a table of type data.frame")
Expand Down Expand Up @@ -107,9 +105,7 @@ add_var_random_int <- function(data, name = "random_int",
seed) {

# data table available?
if (missing(data)) {
stop("data is missing")
}
rlang::check_required(data)

if (!is.data.frame(data)) {
stop("expect a table of type data.frame")
Expand Down
6 changes: 3 additions & 3 deletions R/create-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ create_data_person <- function(obs = 1000, add_id = FALSE, seed = 123) {
#' * female_ind = Gender of customer is female (1 = yes, 0 = no)
#' * fixedvoice_ind = Customer has a fixed voice product (1 = yes, 0 = no)
#' * fixeddata_ind = Customer has a fixed data product (1 = yes, 0 = no)
#' * fixedtv_ind = Customer has a fixed tv product (1 = yes, 0 = no)
#' * fixedtv_ind = Customer has a fixed TV product (1 = yes, 0 = no)
#' * mobilevoice_ind = Customer has a mobile voice product (1 = yes, 0 = no)
#' * mobiledata_prd = Customer has a mobile data product (NO/MOBILE STICK/BUSINESS)
#' * bbi_speed_ind = Customer has a Broadband Internet (BBI) with extra speed
Expand All @@ -237,9 +237,9 @@ create_data_person <- function(obs = 1000, add_id = FALSE, seed = 123) {
#' @param obs Number of observations
#' @param target_name Variable name of target
#' @param factorise_target Should target variable be factorised?
#' (from 0/1 to facotr no/yes)?
#' (from 0/1 to factor no/yes)?
#' @param target1_prob Probability that target = 1
#' @param add_extreme Add an obervation with extreme values?
#' @param add_extreme Add an observation with extreme values?
#' @param flip_gender Should Male/Female be flipped in data?
#' @param add_id Add an id-variable to data?
#' @param seed Seed for randomization
Expand Down

0 comments on commit f7145b6

Please sign in to comment.