Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/erictleung/hp

Pipe a function into help()
https://github.com/erictleung/hp

documentation help magrittr pipe r rstats rstudio

Last synced: 17 days ago
JSON representation

Pipe a function into help()

Awesome Lists containing this project

README

        

---
output: github_document
---

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

# hp

[![R-CMD-check](https://github.com/erictleung/hp/workflows/R-CMD-check/badge.svg)](https://github.com/erictleung/hp/actions)

The goal of hp is to allow you to pipe a function into help using the {magrittr}
pipe, `%>%`.

![Demo of the h function using code shown in the examples section](man/figures/hp.gif)

## Installation

The development version from [GitHub](https://github.com/erictleung/hp) with:

```r
# install.packages("devtools")
remotes::install_github("erictleung/hp")
```

## Example

This is a basic example which shows you how to solve a common problem:

```{r example, eval=FALSE}
library(hp)
library(dplyr)

# Simple single function
t.test %>% h

# Simple single function with parentheses
dim() %>% h

# Function but specifying package
dplyr::across %>% h

# Function but specifying package with parentheses
dplyr::summarise() %>% h
```

## Notes

The `h()` function is designed to only work interactively.

Additionally, this package was created because the {magrittr} pipe doesn't play
well with piping in functions into the `help()` function.

This was fixed with the new native R pipe operator, `|>`.

```r
dim |> help()
```

Note, the left side should not have parentheses or R will warn you that the
`help()` function requires, "a name, length-one character vector or reserved
word."