knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
NoBodySorrow (nbs) is an R package with a range of functions to improve programming workflow in R.
detach(package:nbs, unload=TRUE) library(utils) remove.packages("nbs") devtools::install_github("mikeniemant/nbs")
library(nbs) library(tidymodels) theme_set(theme_bw() + theme(plot.title = element_text(hjust = 0.5)))
data(single_model_tibble)
single_model_tibble
data(multi_model_tibble)
multi_model_tibble
base_nbt <- computeBaseNetBenefit(single_model_tibble$y)
nbt <- computeNetBenefit(pt = base_nbt$pt, y = single_model_tibble$y, pred = single_model_tibble$pred) nbt <- base_nbt %>% left_join(nbt, by = "pt") ggplot(nbt %>% pivot_longer(cols = -pt, names_to = "model", values_to = "nbt") %>% filter(nbt >= -0.1), aes(x = pt, y = nbt, colour = model, linetype = model)) + geom_line() + labs(x = "Threshold probability (%)", y = "Net benefit", colour = "Model", linetype = "Model")
computeCalibration(labs = single_model_tibble$y, preds = single_model_tibble$pred, event_level = "1")
dat <- multi_model_tibble %>% nest(dat = c(y, pred)) %>% mutate(cal = map(dat, ~ computeCalibration(labs = .x$y, preds = .x$pred, event_level = "1", plot = F))) # Plot calibration curve for all models plotCalibration(dat %>% unnest(cal), group = "model")
dat <- multi_model_tibble %>% nest(dat = c(y, pred)) %>% mutate(pr = map(dat, ~ .x %>% pr_curve(pred, truth = y, event_level = "second"))) %>% unnest(pr) plotPrc(dat, group = "model")
dat <- multi_model_tibble %>% nest(dat = c(y, pred)) %>% mutate(roc = map(dat, ~ .x %>% roc_curve(pred, truth = y, event_level = "second"))) %>% unnest(roc) plotRoc(dat, group = "model")
Clear work space - Remove all objects in environment - (Close any SQL connections) - (Close all clusters)
Find all #TODO
statements in all .R and .Rmd files in a directory.
Finds and replaces a particular pattern in all .R and .Rmd files in a directory.
Compute memory size of objects in the R environment.
Open a new issue here for any bug reports or feature requests.
Copyright (C) Michael Niemantsverdriet, the Netherlands, 2022, all rights reserved. Use for personal and educational purposes.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.