Skip to content

Commit

Permalink
lots of clean up for CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
ndphillips committed Jul 16, 2022
1 parent d68fa0b commit 0ca52e9
Show file tree
Hide file tree
Showing 29 changed files with 65 additions and 35 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: FFTrees
Type: Package
Title: Generate, Visualise, and Evaluate Fast-and-Frugal Decision Trees
Version: 1.6.1.9000
Version: 1.6.2
Date: 2022-07-11
Authors@R: c(person("Nathaniel", "Phillips", role = c("aut", "cre"),
email = "Nathaniel.D.Phillips.is@gmail.com"),
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# develop
# 1.6.2

* Internal cleanup to get package back on CRAN.

## 1.6.1

Expand Down
2 changes: 1 addition & 1 deletion R/FFTreesguide_function.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' Opens the FFTrees package guide
#' @importFrom utils vignette
#' @export
#' @return No return value, called for side effects
#'

FFTrees.guide <- function() {
vignette("guide", package = "FFTrees")
}
5 changes: 2 additions & 3 deletions R/fftrees_create.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ fftrees_create <- function(data = NULL,

## Make criterion logical

if (class(data[[criterion_name]]) %in% c("character", "factor")) {
if (inherits(data[[criterion_name]], "character") |
inherits(data[[criterion_name]], "factor")) {

# Save original values as decision.labels
decision.labels <- unique(data[[criterion_name]])
Expand All @@ -313,8 +314,6 @@ fftrees_create <- function(data = NULL,
}
}



## Criterion is in data.test

if (!is.null(data.test)) {
Expand Down
1 change: 1 addition & 0 deletions R/fftrees_define.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#'
#' @export
#' @keywords internal
#' @return An FFTrees object with tree definitions
#'
#'
fftrees_define <- function(x, object = NULL) {
Expand Down
4 changes: 1 addition & 3 deletions R/fftrees_threshold_factor_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @import testthat
#' @importFrom magrittr "%>%"
#' @export
#'
#' @return A data frame containing accuracy statistics for several factor thresholds
#'
fftrees_threshold_factor_grid <- function(thresholds = NULL,
cue_v = NULL,
Expand Down Expand Up @@ -161,7 +161,5 @@ fftrees_threshold_factor_grid <- function(thresholds = NULL,
)
}



return(results)
}
3 changes: 2 additions & 1 deletion R/fftrees_threshold_numeric_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#' @param cost.outcomes list. A list of length 4 with names 'hi', 'fa', 'mi', and 'cr' specifying the costs of a hit, false alarm, miss, and correct rejection rspectively. E.g.; \code{cost.outcomes = listc("hi" = 0, "fa" = 10, "mi" = 20, "cr" = 0)} means that a false alarm and miss cost 10 and 20 respectively while correct decisions have no cost.
#' @param goal.threshold character. A string indicating the statistic to maximize when calculting cue thresholds: "acc" = overall accuracy, "wacc" = weighted accuracy, "bacc" = balanced accuracy
#'
#'
#' @export
#'
#' @return A data frame containing accuracy statistics for several numeric thresholds
#'
fftrees_threshold_numeric_grid <- function(thresholds,
cue_v,
criterion_v,
Expand Down
3 changes: 2 additions & 1 deletion R/fftrees_wordstofftrees.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

#' Converts text describing an FFT into an FFT definition.
#'
#' @param x FFTrees.
#' @param my.tree string. A string defining an FFT
#'
#' @export
#'
#' @return An FFTrees object with a new definition defined by my.tree
#'
#' @importFrom stringr str_extract str_detect

fftrees_wordstofftrees <- function(x,
Expand Down
4 changes: 2 additions & 2 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ comp.pred <- function(formula,

try.pred <- try(predict(train.mod, data.test), silent = TRUE)

if (class(try.pred) == "try-error") {
if (inherits(try.pred, "try-error")) {
warning("svm crashed predicting new data. That's all I can say")

pred.test <- NULL
Expand Down Expand Up @@ -446,7 +446,7 @@ comp.pred <- function(formula,

try.pred <- try(predict(train.mod, data.test.2), silent = TRUE)

if (class(try.pred) == "try-error") {
if (inherits(try.pred, "try-error")) {
warning("randomForest crashed predicting new data. That's all I can say")

pred.test <- NULL
Expand Down
2 changes: 1 addition & 1 deletion R/inwords.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @param x FFTrees.
#' @param tree numeric. The tree to display
#'
#' @return A string describing an FFT
#' @export
#'
inwords <- function(x, tree = 1) {
Expand Down
9 changes: 5 additions & 4 deletions R/plotFFTrees_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#' @importFrom graphics text points abline legend mtext segments rect arrows axis par layout plot
#' @importFrom grDevices gray col2rgb rgb
#' @export
#' @return A plot vizualizing an FFT
#' @examples
#'
#' # Create FFTrees of the heart disease data
Expand Down Expand Up @@ -249,7 +250,7 @@ plot.FFTrees <- function(x = NULL,
main <- x$params$main
}
} else {
if (class(data) == "character") {
if (inherits(data, "character")) {
if (data == "train") {
main <- "Data (Training)"
}
Expand All @@ -258,7 +259,7 @@ plot.FFTrees <- function(x = NULL,
}
}

if (class(data) == "data.frame") {
if (inherits(data, "data.frame")) {
main <- "Test Data"
}
}
Expand All @@ -275,7 +276,7 @@ plot.FFTrees <- function(x = NULL,
tree <- which.tree
}

if (class(x) != "FFTrees") {
if (!inherits(x, "FFTrees")) {
stop("You did not include a valid FFTrees class object or specify the tree directly with level.names, level.classes (etc.). Either create a valid FFTrees object with FFTrees() or specify the tree directly.")
}

Expand All @@ -289,7 +290,7 @@ plot.FFTrees <- function(x = NULL,
stop(paste("You asked for a tree that does not exist. This object has", x$trees$n, "trees"))
}

if (class(data) == "character") {
if (inherits(data, "character")) {
if (data == "test" & is.null(x$trees$stats$test)) {
stop("You asked to plot the test data but there are no test data in the FFTrees object")
}
Expand Down
1 change: 1 addition & 0 deletions R/printFFTrees_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @param x FFTrees. A FFTrees x created from FFTrees()
#' @param tree integer. The tree to explore.
#' @param ... additional arguments passed to print.
#' @return Prints summary information about an FFT to the console
#' @export

print.FFTrees <- function(x = NULL,
Expand Down
3 changes: 1 addition & 2 deletions R/showcues_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
#' @param main Main plot description
#' @param top An integer indicating how many of the top cues to highlight
#' @importFrom graphics text points abline legend mtext segments rect arrows axis par layout plot
#' @return A plot showing cue accuracies from an FFTrees object in a ROC space
#' @export
#'

showcues <- function(x = NULL,
data = "train",
cue.accuracies = NULL,
main = NULL,
top = 5) {

par0 <- par(no.readonly = TRUE)
on.exit(par(par0), add = TRUE)

Expand Down
4 changes: 1 addition & 3 deletions R/summaryFFTrees_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#' @param object FFTrees.
#' @param tree integer. The tree to summarise
#' @param ... additional arguments (currently ignored)
#' @return A data frame comtaining summary information about an FFT
#' @export
#'

summary.FFTrees <- function(object,
tree = 1,
...) {
Expand Down Expand Up @@ -143,7 +143,5 @@ summary.FFTrees <- function(object,
"spec"
)



return(summary.df)
}
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ knitr::opts_chunk$set(
)
```

# FFTrees
# FFTrees `r packageVersion("FFTrees")`

[![Build Status](https://travis-ci.org/ndphillips/FFTrees.svg?branch=master)](https://travis-ci.org/ndphillips/FFTrees)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/FFTrees)](https://CRAN.R-project.org/package=FFTrees)
[![Downloads](https://cranlogs.r-pkg.org/badges/FFTrees?color=brightgreen)](https://www.r-pkg.org/pkg/FFTrees)

The goal of FFTrees is to create and visualize fast-and-frugal decision trees (FFTs) from data with a binary outcome following the methods described in [Phillips, Neth, Woike & Gaissmaier (2017)](http://journal.sjdm.org/17/17217/jdm17217.pdf).
The goal of FFTrees is to create and visualize fast-and-frugal decision trees (FFTs) from data with a binary outcome following the methods described in [Phillips, Neth, Woike & Gaissmaier (2017)](https://journal.sjdm.org/17/17217/jdm17217.pdf).

## Installation

Expand Down Expand Up @@ -105,7 +105,7 @@ plot(my.fft,

Phillips, Nathaniel D., Neth, Hansjoerg, Woike, Jan K., & Gaissmaier, W. (2017). FFTrees: A toolbox to create, visualize, and evaluate fast-and-frugal decision trees. *Judgment and Decision Making*, 12(4), 344-368.

We had a lot of fun creating FFTrees and hope you like it too! We have an article introducing the `FFTrees` package in the journal Judgment and Decision Making titled FFTrees: [A toolbox to create, visualize,and evaluate fast-and-frugal decision trees](http://journal.sjdm.org/17/17217/jdm17217.pdf). We encourage you to read the article to learn more about the history of FFTs and how the FFTrees package creates them.
We had a lot of fun creating FFTrees and hope you like it too! We have an article introducing the `FFTrees` package in the journal Judgment and Decision Making titled FFTrees: [A toolbox to create, visualize,and evaluate fast-and-frugal decision trees](https://journal.sjdm.org/17/17217/jdm17217.pdf). We encourage you to read the article to learn more about the history of FFTs and how the FFTrees package creates them.

If you use FFTrees in your work, please cite us and spread the word so we can continue developing the package

Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# FFTrees
# FFTrees 1.6.2

[![Build
Status](https://travis-ci.org/ndphillips/FFTrees.svg?branch=master)](https://travis-ci.org/ndphillips/FFTrees)
Expand All @@ -11,7 +11,7 @@ Status](https://travis-ci.org/ndphillips/FFTrees.svg?branch=master)](https://tra
The goal of FFTrees is to create and visualize fast-and-frugal decision
trees (FFTs) from data with a binary outcome following the methods
described in [Phillips, Neth, Woike & Gaissmaier
(2017)](http://journal.sjdm.org/17/17217/jdm17217.pdf).
(2017)](https://journal.sjdm.org/17/17217/jdm17217.pdf).

## Installation

Expand All @@ -38,10 +38,9 @@ library(FFTrees)
#> / \
#> F O
#> / \
#> F Trees 1.6.1
#> F Trees 1.6.2
#>
#> Email: Nathaniel.D.Phillips.is@gmail.com
#> LinkedIn: linkedin.com/in/nathanieldphillips/
#> FFTrees.guide() opens the main guide.
```

Expand Down Expand Up @@ -155,13 +154,13 @@ heart.fft$competition$test
#> 1 fftrees 153 64 19 9 61 0.8767123 0.7625 0.2375 0.7710843 0.8714286
#> 2 lr 153 55 13 18 67 0.7534247 0.8375 0.1625 0.8088235 0.7882353
#> 3 cart 153 50 19 23 61 0.6849315 0.7625 0.2375 0.7246377 0.7261905
#> 4 rf 153 58 8 15 72 0.7945205 0.9000 0.1000 0.8787879 0.8275862
#> 4 rf 153 58 9 15 71 0.7945205 0.8875 0.1125 0.8656716 0.8255814
#> 5 svm 153 55 7 18 73 0.7534247 0.9125 0.0875 0.8870968 0.8021978
#> acc bacc cost cost_decisions cost_cues
#> 1 0.8169935 0.8196062 0.1830065 0.1830065 0
#> 2 0.7973856 0.7954623 0.2026144 0.2026144 NA
#> 3 0.7254902 0.7237158 0.2745098 0.2745098 NA
#> 4 0.8496732 0.8472603 0.1503268 0.1503268 NA
#> 4 0.8431373 0.8410103 0.1568627 0.1568627 NA
#> 5 0.8366013 0.8329623 0.1633987 0.1633987 NA
```

Expand Down Expand Up @@ -206,7 +205,7 @@ We had a lot of fun creating FFTrees and hope you like it too! We have
an article introducing the `FFTrees` package in the journal Judgment and
Decision Making titled FFTrees: [A toolbox to create, visualize,and
evaluate fast-and-frugal decision
trees](http://journal.sjdm.org/17/17217/jdm17217.pdf). We encourage you
trees](https://journal.sjdm.org/17/17217/jdm17217.pdf). We encourage you
to read the article to learn more about the history of FFTs and how the
FFTrees package creates them.

Expand Down
3 changes: 3 additions & 0 deletions man/FFTrees.guide.Rd

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

3 changes: 3 additions & 0 deletions man/fftrees_define.Rd

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

3 changes: 3 additions & 0 deletions man/fftrees_threshold_factor_grid.Rd

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

3 changes: 3 additions & 0 deletions man/fftrees_threshold_numeric_grid.Rd

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

3 changes: 3 additions & 0 deletions man/fftrees_wordstofftrees.Rd

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

Binary file modified man/figures/README-example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions man/inwords.Rd

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

3 changes: 3 additions & 0 deletions man/plot.FFTrees.Rd

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

3 changes: 3 additions & 0 deletions man/print.FFTrees.Rd

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

3 changes: 3 additions & 0 deletions man/showcues.Rd

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

3 changes: 3 additions & 0 deletions man/summary.FFTrees.Rd

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

Loading

0 comments on commit 0ca52e9

Please sign in to comment.