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

https://github.com/UchidaMizuki/partialised

Partialised Functions
https://github.com/UchidaMizuki/partialised

Last synced: 4 months ago
JSON representation

Partialised Functions

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%"
)
```

# partialised

[![CRAN status](https://www.r-pkg.org/badges/version/partialised)](https://CRAN.R-project.org/package=partialised)

partialised provides a 'partialised' class that extends the partialising
function of 'purrr' by making it easier to change the arguments. This is
similar to the function-like object in 'Julia'
().

## Installation

You can install the development version of partialised from [GitHub](https://github.com/) with:

``` r
# the released version from CRAN:
install.packages("partialised")

# the development version from GitHub:
# install.packages("devtools")
devtools::install_github("UchidaMizuki/partialised")
```

## Example

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

```{r example}
library(partialised)

dist <- function(x, y) {
sqrt(x ^ 2 + y ^ 2)
}

pdist <- new_partialised(dist,
list(x = 3))
pdist
pdist(y = 4)

arguments(pdist)
pdist$x
pdist$y

pdist$x <- 6
pdist(y = 8)

pdist$y <- 8
pdist()
```