depigner ![](https://img.shields.io/badge/WEB site-click me-orange.svg)

A utility package to help you deal with pigne

| | | | | |:----------------|:-------------------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------:| | Development | Devel version | lifecycle | last commit | | CRAN | CRAN status | downloads | downloads | | CI | R build status | Coverage status | code size |

Pigna [pìn'n'a] is the Italian word for pine cone.^[You can find all the possible meanings of pigna here, and you can listen how to pronounce it here. Note: the Italian plural for "pigna" is "pigne" [pìn'n'e].] In jargon, it's used to identify something (like a task...) boring, banal, annoying, painful, frustrating and maybe even with a not so beautiful or rewarding result, just like the obstinate act of trying to challenge yourself in extracting pine nuts from a pine cone, provided that at the end you will find at least one inside it...

knitr::opts_chunk$set(
  eval     = TRUE,
  collapse = TRUE,
  comment  = "#>"
)
library(magrittr)
library(pander)

Overview

This package aims to provide some useful functions to be used to solve small everyday problems of coding or analyzing data with R. The hope is to provide solutions to that kind of problems which would be normally solved using quick-and-dirty (ugly and maybe even wrong) patches.

| Tools Category | Function(s) | Aim | |:-----------------------------------------|:--------------------------|:-------------------------------------------------------------------------| | Harrell's verse | tidy_summary() | pander-ready data frame from Hmisc::summary() | |   | paired_test_continuous | Paired test for continuous variable into Hmisc::summary | |   | paired_test_categorical | Paired test for categorical variable into Hmisc::summary | |   | adjust_p() | Adjusts P-values for multiplicity of tests at tidy_summary() | |   | summary_interact() | data frame of OR for interaction from rms::lrm() | |   | htypes() | Will be your variables continuous or categorical in Hmisc::describe()? | | Statistical | ci2p() | Get P-value form estimation and confidence interval | | Programming | pb_len() | Quick set-up of a progress::progress_bar() progress bar | |   | install_pkg_set() | Politely install set of packages (topic-related sets at ?pkg_sets) | |   | view_in_excel() | Open a data frame in Excel, even in the middle of a pipe chain, on interactive session only | | Development | use_ui() | Activate {usethis} user interface into your own package | |   | please_install() | Politely ask the user to install a package | |   | imported_from() | List packages imported from a package (which has to be installed) | | Telegram | start_bot_for_chat() | Quick start of a {telegram.bot} Telegram's bot | |   | send_to_telegram() | Unified wrapper to send someRthing to a Telegram chat | |   | errors_to_telegram() | Divert all your error messages from the console to a Telegram chat | | Why not?! | gdp() | Do you have TOO much pignas in your back?! ... try this out ;-) |

Installation

You can install the released version of {depigner} from CRAN with:

install.packages("depigner")

You can install the development version from GitHub calling:

# install.packages("devtools")
devtools::install_github("CorradoLanera/depigner")

Next, you can attach it to your session by:

library(depigner)

Provided Tools

Harrell's Verse Tools

Currently it is tested for method reverse only:

library(rms)
  options(datadist = 'dd')
library(survival)
library(pander)

dd <- datadist(iris)
my_summary <- summary(Species ~., data = iris, method = "reverse")
tidy_summary(my_summary) %>% 
  pander()


dd <<- datadist(heart) # this to face a package build issue,
                       # use standard `<-` into analyses
surv <- Surv(heart$start, heart$stop, heart$event)
f    <- cph(surv ~ age + year + surgery, data = heart)
my_summary <- summary(f)
tidy_summary(my_summary) %>% 
  pander()
data(Arthritis)
# categorical -------------------------
## two groups
summary(Treatment ~ Sex,
    data    = Arthritis,
    method  = "reverse",
    test    = TRUE,
    catTest = paired_test_categorical
)
## more than two groups
summary(Improved ~ Sex,
    data    = Arthritis,
    method  = "reverse",
    test    = TRUE,
    catTest = paired_test_categorical
)

# continuous --------------------------
## two groups
summary(Species ~.,
    data    = iris[iris$Species != "setosa",],
    method  = "reverse",
    test    = TRUE,
    conTest = paired_test_continuous
)
## more than two groups
summary(Species ~.,
    data    = iris,
    method  = "reverse",
    test    = TRUE,
    conTest = paired_test_continuous
)
my_summary <- summary(Species ~., data = iris,
  method = "reverse",
  test = TRUE
)

tidy_summary(my_summary, prtest = "P") %>%
  adjust_p()
data("transplant", package = "survival")
censor_rows <- transplant[['event']] != 'censored' 
transplant <- droplevels(transplant[censor_rows, ])

dd <<- datadist(transplant) # this to face a package build issue,
                            # use standard `<-` into analyses

lrm_mod <- lrm(event ~ rcs(age, 3)*(sex + abo) + rcs(year, 3),
  data = transplant
)
summary_interact(lrm_mod, age, abo) %>%
  pander()

summary_interact(lrm_mod, age, abo, p = TRUE) %>%
  pander()
htypes(mtcars)

desc <- Hmisc::describe(mtcars)
htypes(desc)
htype(desc[[1]])
is_hcat(desc[[1]])
is_hcon(desc[[1]])

Statistical Tools

ci2p(1.125, 0.634,  1.999, log_transform = TRUE)

Programming Tools

pb <- pb_len(100)

for (i in 1:100) {
    Sys.sleep(0.1)
    tick(pb, paste("i = ", i))
}
install_pkg_set() # this install the whole `?pkg_all`
install_pkg_set(pkg_stan)

?pkg_sets
four_cyl_cars <- mtcars %>%
  view_in_excel() %>%
  dplyr::filter(cyl == 4) %>%
  view_in_excel()

four_cyl_cars

Development Tools

# in the initial setup steps of the development of a package
use_ui()
a_pkg_i_miss <- setdiff(available.packages(), installed.packages())[[1]]
please_install(a_pkg_i_miss)
imported_from("depigner")

Telegram Tools

# Set up a Telegram bot. read `?start_bot_for_chat`
start_bot_for_chat()

# Send something to telegram
send_to_telegram("hello world")

library(ggplot2)
gg <- ggplot(mtcars, aes(x = mpg, y = hp, colour = cyl)) +
    geom_point()
send_to_telegram(
  "following an `mtcars` coloured plot",
  parse_mode = "Markdown"
)
send_to_telegram(gg)

# Divert output errors to the telegram bot
errors_to_telegram()

Why Not?!

gdp(7)

Feature request

If you need some more features, please open an issue here.

Bug reports

If you encounter a bug, please file a reprex (minimal reproducible example) here.

Code of Conduct

Please note that the depigner project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Acknowledgements

The {depigner}'s logo was lovely designed by Elisa Sovrano.

Reference

# create a bib file for the R packages used in this document
knitr::write_bib(
  x    = c('rms', 'Hmisc', 'telegram.bot', 'progress', 'usethis',
           'pander'),
  file = 'inst/bib/doc-pkg.bib'
)


CorradoLanera/depigner documentation built on April 26, 2023, 4:34 a.m.