Science Score: 20.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
✓Committers with academic emails
1 of 3 committers (33.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.1%) to scientific vocabulary
Repository
R package for function composition utilizing standard evaluation
Basic Info
- Host: GitHub
- Owner: swang87
- Language: R
- Default Branch: master
- Size: 241 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
- Releases: 0
Metadata Files
README.md
fc
This is an R package that provides a streamlined, standard evaluation-based approach to function composition.
Using fc, a sequence of functions can be composed together such that returned objects from composed functions are used as intermediate values directly passed to the next function.
Installation
To install this package in R, you can install it via the devtools package:
devtools::install_github("swang87/fc")
Usage
The package can then be loaded using:
library(fc)
The workhorse of the package is the fc() function. Its first argument is either a named function or an anonymous function; subsequent arguments must be named arguments of this function.
Getting Started
We can create a new function that uses partial function valuation to display the first 50 rows of a dataset with:
head50 <- fc(head, n=50)
The return function has a single argument x, inherited from the head() function. The function head50() consists of:
function (x)
{
head(x, n = 50)
}
In order to perform function composition, multiple fc() calls could be used in a nested manner:
summary50 <- fc(summary, object=fc(head, n = 50)(object))
The pipe-forward operator %>% is also supported for defining a pipeline functions to be run from left-to-right. Note differences in usage compared to magrittr and other packages in the Tidyverse.
summary50 <- fc(head, n=50) %>% summary
In particular, the pipe-forward operator supported by fc cannot accept a data object on its lefthand side. If one wishes to run the composed function on a data object without intermediate storage of the function itself, the following syntax is permissible:
(fc(head, n=50) %>% summary)(x)
Examples
Example 1
log_sqrt_fc_pipe <- fc(log, x=x) %>% fc(sqrt, x=x)
This function takes the square root of the log of an input argument x.
Example 2
get_sepal2_pipe <- fc(function(x, cols) {x[sample(1:nrow(x)), cols]},
cols = grep("Sepal", colnames(x))) %>%
fc(head, n = 10) %>% summary
More Information
More details can be found in our working paper.
Owner
- Name: Susan Wang
- Login: swang87
- Kind: user
- Location: San Mateo, CA
- Repositories: 8
- Profile: https://github.com/swang87
GitHub Events
Total
Last Year
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Michael Kane | k****s@g****m | 26 |
| swang87 | x****g@y****u | 17 |
| Susan Wang | s****7 | 4 |
Committer Domains (Top 20 + Academic)
Packages
- Total packages: 1
-
Total downloads:
- cran 187 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: fc
Standard Evaluation-Based Multivariate Function Composition
- Homepage: https://github.com/swang87/fc
- Documentation: http://cran.r-project.org/web/packages/fc/fc.pdf
- License: GPL-2
-
Latest release: 0.1.0
published almost 8 years ago
Rankings
Maintainers (1)
Dependencies
- codetools * imports