knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

  library(magrittr)

envFunc: an R package of tools to help with other envPackages

The goal of envFunc is to store functions that help across the other envPackages.

Installation

envFunc is not on CRAN.

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("Acanthiza/envFunc")

Load envFunc

library("envFunc")

Add time stamp

add_time_stamp adds the creation time of an object as an attribute.

  temp <- cars %>%
    envFunc::add_time_stamp()

  attr(temp, "ctime")

Add a likelihood classification

  x <- tibble::tibble(x = rbeta(10, 1, 1)) %>%
    add_likelihood(x)

  x

What else is in envFunc

The following functions and data sets are provided in envFunc. See https://acanthiza.github.io/envFunc/ for more examples.

  get_name_title <- function(text) {

    tibble::enframe(text
                    , name = NULL
                    , value = "description"
                    ) %>%
      dplyr::filter(grepl("title", description)) %>%
      dplyr::mutate(description = gsub("\\\\|title", "", description)
                    , description = gsub("^\\{|\\}$", "", description)
                    )

  }

  manuals <- fs::dir_info("man") %>%
    dplyr::select(path) %>%
    dplyr::filter(grepl("Rd$", path)
                  , !grepl("pipe", path)
                  ) %>%
    dplyr::mutate(object = gsub("man\\/|\\.Rd","",path)
                  , class = purrr::map_chr(object, ~envFunc::vec_to_sentence(class(get(.))))
                  , text = purrr::map(path, readLines)
                  , text = purrr::map(text, get_name_title)
                  , object = paste0("`envFunc::"
                                    , object
                                    , "`"
                                    )
                  ) %>%
    tidyr::unnest(cols = c(text))

  knitr::kable(manuals[,2:4])


Acanthiza/envFunc documentation built on Aug. 19, 2024, 4:50 a.m.