Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/cran/cutpointr
12 May 2022, 17:57:39 UTC
  • Code
  • Branches (12)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/0.7.2
    • refs/tags/0.7.3
    • refs/tags/0.7.4
    • refs/tags/0.7.6
    • refs/tags/1.0.0
    • refs/tags/1.0.1
    • refs/tags/1.0.2
    • refs/tags/1.0.32
    • refs/tags/1.1.0
    • refs/tags/1.1.1
    • refs/tags/1.1.2
    No releases to show
  • da13f07
  • /
  • R
  • /
  • plot_x.R
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:f4a402305d656c7e4b4984a6f52a41d765fa3299
origin badgedirectory badge
swh:1:dir:a9efd1deea485f19e4e36bfcd9b5108a56759d62
origin badgerevision badge
swh:1:rev:8883cb6d23c8c690e6eeb8a8d074a5508e76f3d7
origin badgesnapshot badge
swh:1:snp:59fa548f9fdef2e9cfbec66f8a33531d45433c4b

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 8883cb6d23c8c690e6eeb8a8d074a5508e76f3d7 authored by Christian Thiele on 27 March 2019, 09:10:03 UTC
version 0.7.6
Tip revision: 8883cb6
plot_x.R
#' Plot the distribution of the independent variable per class from a cutpointr object
#'
#' Given a \code{cutpointr} object this function plots the distribution(s) of the
#' independent variable(s) and the respective cutpoints per class.
#' @param x A cutpointr object.
#' @param display_cutpoint (logical) Whether or not to display the optimal
#' cutpoint as a vertical line.
#' @param ... Additional arguments (unused).
#' @examples
#' opt_cut <- cutpointr(suicide, dsi, suicide)
#' plot_x(opt_cut)
#'
#' ## With subgroup
#' opt_cut_2groups <- cutpointr(suicide, dsi, suicide, gender)
#' plot_x(opt_cut_2groups)
#' @family cutpointr plotting functions
#' @export
plot_x <- function(x, display_cutpoint = TRUE, ...) {

    args <- list(...)
    predictor <- as.name(x$predictor[1])
    outcome <- as.name(x$outcome[1])

    if (!(has_column(x, "subgroup"))) {
        dts <- "data"
        dts_cutpoint <- "optimal_cutpoint"
        fll <- NULL
        clr <- NULL
        clr_roc <- NULL
        transparency <- 1
    } else {
        dts <- c("data", "subgroup")
        dts_cutpoint <- c("subgroup", "optimal_cutpoint")
        fll <- "subgroup"
        clr <- "subgroup"
        clr_roc <- ~ subgroup
        transparency <- 0.6
    }

    res_unnested <- x %>%
        dplyr::select_(.dots = dts) %>%
        tidyr::unnest_(unnest_cols = "data")
    if (!(has_column(x, "subgroup"))) {
        col <- NULL
    } else {
        res_unnested <- dplyr::full_join(res_unnested,
                                         x[, c("optimal_cutpoint", "subgroup")],
                                         by = "subgroup")
        col <- ~ subgroup
    }
    if (all(na_inf_omit(unlist(dplyr::select_(res_unnested, .dots = predictor))) %% 1 == 0) |
        only_one_unique(
            na_inf_omit(unlist(dplyr::select_(res_unnested, .dots = predictor)))
        )) {
        all_integer = TRUE
        dist_plot <- ggplot2::geom_bar(alpha = transparency, position = "identity")
    } else {
        all_integer = FALSE
        dist_plot <- ggplot2::geom_density(alpha = transparency)
    }
    dist <- ggplot2::ggplot(res_unnested,
                            ggplot2::aes_string(x = predictor,
                                                fill = fll, color = clr)) +
        dist_plot +
        # facet by class because always 2
        ggplot2::facet_wrap(outcome, scales = "free_y") +
        ggplot2::ggtitle("Independent variable",
                         "optimal cutpoint and distribution by class") +
        ggplot2::xlab("value")
    if (display_cutpoint) {
        cutpoint_dat <- x %>%
            dplyr::select_(.dots = dts_cutpoint)
        if (is.list(x$optimal_cutpoint)) {
            cutpoint_dat <- tidyr::unnest_(cutpoint_dat)
        }
        dist <- dist +
        ggplot2::geom_vline(data = cutpoint_dat,
                            ggplot2::aes_(xintercept = ~ optimal_cutpoint,
                                          color = col), show.legend = FALSE)
    }

    if (!all_integer) dist <- dist + ggplot2::geom_rug(alpha = 0.5)
    return(dist)
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API